Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move getLocalTime() as static inline function to DateMath
https://bugs.webkit.org/show_bug.cgi?id=92955

Reviewed by Ryosuke Niwa.

getCurrentLocalTime() and getLocalTime() has been superseded with the
GregorianDateTime class. So we can move it into DateMath.cpp as an static inline
function. This allows us to remove the dependecy on time() and localtime()
for Windows CE, where this functions require the ce_time library to work.

Source/JavaScriptCore:

* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:

Source/WTF:

* wtf/CurrentTime.cpp:
(WTF):
* wtf/CurrentTime.h:
* wtf/DateMath.cpp:
(WTF):
(WTF::getLocalTime):


Canonical link: https://commits.webkit.org/110909@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@124560 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
paroga committed Aug 3, 2012
1 parent 78bfaee commit ff88294
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 23 deletions.
14 changes: 14 additions & 0 deletions Source/JavaScriptCore/ChangeLog
@@ -1,3 +1,17 @@
2012-08-02 Patrick Gansterer <paroga@webkit.org>

Move getLocalTime() as static inline function to DateMath
https://bugs.webkit.org/show_bug.cgi?id=92955

Reviewed by Ryosuke Niwa.

getCurrentLocalTime() and getLocalTime() has been superseded with the
GregorianDateTime class. So we can move it into DateMath.cpp as an static inline
function. This allows us to remove the dependecy on time() and localtime()
for Windows CE, where this functions require the ce_time library to work.

* JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:

2012-08-02 Filip Pizlo <fpizlo@apple.com>

ASSERTION FAILED: at(m_compileIndex).canExit() || m_isCheckingArgumentTypes
Expand Down
Expand Up @@ -201,7 +201,6 @@ EXPORTS
?getCallData@JSCell@JSC@@SA?AW4CallType@2@PAV12@AATCallData@2@@Z
?getCallableObjectSlow@JSC@@YAPAVJSCell@1@PAV21@@Z
?getConstructData@JSCell@JSC@@SA?AW4ConstructType@2@PAV12@AATConstructData@2@@Z
?getCurrentLocalTime@WTF@@YAXPAUtm@@@Z
?getObject@JSCell@JSC@@QAEPAVJSObject@2@XZ
?getOwnPropertyDescriptor@JSGlobalObject@JSC@@SA_NPAVJSObject@2@PAVExecState@2@VPropertyName@2@AAVPropertyDescriptor@2@@Z
?getOwnPropertyDescriptor@JSObject@JSC@@SA_NPAV12@PAVExecState@2@VPropertyName@2@AAVPropertyDescriptor@2@@Z
Expand Down
19 changes: 19 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,22 @@
2012-08-02 Patrick Gansterer <paroga@webkit.org>

Move getLocalTime() as static inline function to DateMath
https://bugs.webkit.org/show_bug.cgi?id=92955

Reviewed by Ryosuke Niwa.

getCurrentLocalTime() and getLocalTime() has been superseded with the
GregorianDateTime class. So we can move it into DateMath.cpp as an static inline
function. This allows us to remove the dependecy on time() and localtime()
for Windows CE, where this functions require the ce_time library to work.

* wtf/CurrentTime.cpp:
(WTF):
* wtf/CurrentTime.h:
* wtf/DateMath.cpp:
(WTF):
(WTF::getLocalTime):

2012-08-02 Patrick Gansterer <paroga@webkit.org>

[WINCE] Return 0 at calculateDSTOffset(double, double)
Expand Down
17 changes: 0 additions & 17 deletions Source/WTF/wtf/CurrentTime.cpp
Expand Up @@ -335,21 +335,4 @@ double monotonicallyIncreasingTime()

#endif // !PLATFORM(CHROMIUM)

void getLocalTime(const time_t* localTime, struct tm* localTM)
{
#if COMPILER(MSVC7_OR_LOWER) || COMPILER(MINGW) || OS(WINCE)
*localTM = *localtime(localTime);
#elif COMPILER(MSVC)
localtime_s(localTM, localTime);
#else
localtime_r(localTime, localTM);
#endif
}

void getCurrentLocalTime(struct tm* localTM)
{
time_t localTime = time(0);
getLocalTime(&localTime, localTM);
}

} // namespace WTF
5 changes: 0 additions & 5 deletions Source/WTF/wtf/CurrentTime.h
Expand Up @@ -47,9 +47,6 @@ inline double currentTimeMS()
return currentTime() * 1000.0;
}

WTF_EXPORT_PRIVATE void getLocalTime(const time_t* localTime, struct tm* localTM);
WTF_EXPORT_PRIVATE void getCurrentLocalTime(struct tm* localTM);

// Provides a monotonically increasing time in seconds since an arbitrary point in the past.
// On unsupported platforms, this function only guarantees the result will be non-decreasing.
WTF_EXPORT_PRIVATE double monotonicallyIncreasingTime();
Expand All @@ -58,8 +55,6 @@ WTF_EXPORT_PRIVATE double monotonicallyIncreasingTime();

using WTF::currentTime;
using WTF::currentTimeMS;
using WTF::getCurrentLocalTime;
using WTF::getLocalTime;
using WTF::monotonicallyIncreasingTime;

#endif // CurrentTime_h
13 changes: 13 additions & 0 deletions Source/WTF/wtf/DateMath.cpp
Expand Up @@ -127,6 +127,19 @@ static const int firstDayOfMonth[2][12] = {
{0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335}
};

#if !OS(WINCE)
static inline void getLocalTime(const time_t* localTime, struct tm* localTM)
{
#if COMPILER(MSVC7_OR_LOWER) || COMPILER(MINGW)
*localTM = *localtime(localTime);
#elif COMPILER(MSVC)
localtime_s(localTM, localTime);
#else
localtime_r(localTime, localTM);
#endif
}
#endif

bool isLeapYear(int year)
{
if (year % 4 != 0)
Expand Down

0 comments on commit ff88294

Please sign in to comment.