Title: [113295] trunk/Source
Revision
113295
Author
[email protected]
Date
2012-04-04 23:40:16 -0700 (Wed, 04 Apr 2012)

Log Message

Add WTF::getCurrentLocalTime()
https://bugs.webkit.org/show_bug.cgi?id=83164

Reviewed by Alexey Proskuryakov.

Replace the calls to WTF::getLocalTime() with time(0) with the new function.
This allows us to use Win32 API on windows to get the same result in a next step.

Source/_javascript_Core:

* _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
* runtime/DateConstructor.cpp:
(JSC::callDate):

Source/WebCore:

* html/FTPDirectoryDocument.cpp:
(WebCore::processFileDateString):
* loader/archive/mhtml/MHTMLArchive.cpp:
(WebCore::MHTMLArchive::generateMHTMLData):

Source/WTF:

Also remove the inline keyword from WTF::getLocalTime(), since there is no need for
it and it will make the later Win32 API changes easier.

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

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (113294 => 113295)


--- trunk/Source/_javascript_Core/ChangeLog	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-04-05 06:40:16 UTC (rev 113295)
@@ -1,3 +1,17 @@
+2012-04-04  Patrick Gansterer  <[email protected]>
+
+        Add WTF::getCurrentLocalTime()
+        https://bugs.webkit.org/show_bug.cgi?id=83164
+
+        Reviewed by Alexey Proskuryakov.
+
+        Replace the calls to WTF::getLocalTime() with time(0) with the new function.
+        This allows us to use Win32 API on windows to get the same result in a next step.
+
+        * _javascript_Core.vcproj/_javascript_Core/_javascript_Core.def:
+        * runtime/DateConstructor.cpp:
+        (JSC::callDate):
+
 2012-04-04  Oliver Hunt  <[email protected]>
 
         Parser fails to revert some state after parsing _expression_ and object literals.

Modified: trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def (113294 => 113295)


--- trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/_javascript_Core/_javascript_Core.vcproj/_javascript_Core/_javascript_Core.def	2012-04-05 06:40:16 UTC (rev 113295)
@@ -195,6 +195,7 @@
     ?getCalculatedDisplayName@JSC@@YA?AVUString@1@PAVExecState@1@PAVJSObject@1@@Z
     ?getCallData@JSCell@JSC@@SA?AW4CallType@2@PAV12@AATCallData@2@@Z
     ?getConstructData@JSCell@JSC@@SA?AW4ConstructType@2@PAV12@AATConstructData@2@@Z
+    ?getCurrentLocalTime@WTF@@YAXPAUtm@@@Z
     ?getObject@JSCell@JSC@@QAEPAVJSObject@2@XZ
     ?getOwnPropertyDescriptor@JSByteArray@JSC@@SA_NPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z
     ?getOwnPropertyDescriptor@JSGlobalObject@JSC@@SA_NPAVJSObject@2@PAVExecState@2@ABVIdentifier@2@AAVPropertyDescriptor@2@@Z

Modified: trunk/Source/_javascript_Core/runtime/DateConstructor.cpp (113294 => 113295)


--- trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/_javascript_Core/runtime/DateConstructor.cpp	2012-04-05 06:40:16 UTC (rev 113295)
@@ -166,9 +166,8 @@
 // ECMA 15.9.2
 static EncodedJSValue JSC_HOST_CALL callDate(ExecState* exec)
 {
-    time_t localTime = time(0);
     tm localTM;
-    getLocalTime(&localTime, &localTM);
+    getCurrentLocalTime(&localTM);
     GregorianDateTime ts(exec, localTM);
     DateConversionBuffer date;
     DateConversionBuffer time;

Modified: trunk/Source/WTF/ChangeLog (113294 => 113295)


--- trunk/Source/WTF/ChangeLog	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/WTF/ChangeLog	2012-04-05 06:40:16 UTC (rev 113295)
@@ -1,3 +1,22 @@
+2012-04-04  Patrick Gansterer  <[email protected]>
+
+        Add WTF::getCurrentLocalTime()
+        https://bugs.webkit.org/show_bug.cgi?id=83164
+
+        Reviewed by Alexey Proskuryakov.
+
+        Replace the calls to WTF::getLocalTime() with time(0) with the new function.
+        This allows us to use Win32 API on windows to get the same result in a next step.
+
+        Also remove the inline keyword from WTF::getLocalTime(), since there is no need for
+        it and it will make the later Win32 API changes easier.
+
+        * WTF.gyp/WTF.gyp:
+        * wtf/CurrentTime.cpp:
+        (WTF::getLocalTime):
+        (WTF::getCurrentLocalTime):
+        * wtf/CurrentTime.h:
+
 2012-04-04  Chris Rogers  <[email protected]>
 
         Web Audio should use MutexTryLocker class

Modified: trunk/Source/WTF/WTF.gyp/WTF.gyp (113294 => 113295)


--- trunk/Source/WTF/WTF.gyp/WTF.gyp	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/WTF/WTF.gyp/WTF.gyp	2012-04-05 06:40:16 UTC (rev 113295)
@@ -129,7 +129,6 @@
         # GLib/GTK, even though its name doesn't really indicate.
         ['exclude', '/(gtk|glib|gobject)/.*\\.(cpp|h)$'],
         ['exclude', '(Default|Gtk|Mac|None|Qt|Win|Wx|Efl|Symbian)\\.(cpp|mm)$'],
-        ['exclude', 'wtf/CurrentTime\\.cpp$'],
         ['exclude', 'wtf/OSRandomSource\\.cpp$'],
         ['exclude', 'wtf/MainThread.cpp$'],
         ['exclude', 'wtf/TC.*\\.(cpp|h)$'],

Modified: trunk/Source/WTF/wtf/CurrentTime.cpp (113294 => 113295)


--- trunk/Source/WTF/wtf/CurrentTime.cpp	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/WTF/wtf/CurrentTime.cpp	2012-04-05 06:40:16 UTC (rev 113295)
@@ -72,14 +72,12 @@
 #include <QElapsedTimer>
 #endif
 
-#if PLATFORM(CHROMIUM)
-#error Chromium uses a different timer implementation
-#endif
-
 namespace WTF {
 
 const double msPerSecond = 1000.0;
 
+#if !PLATFORM(CHROMIUM)
+
 #if OS(WINDOWS)
 
 #if USE(QUERY_PERFORMANCE_COUNTER)
@@ -346,4 +344,23 @@
 
 #endif
 
+#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

Modified: trunk/Source/WTF/wtf/CurrentTime.h (113294 => 113295)


--- trunk/Source/WTF/wtf/CurrentTime.h	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/WTF/wtf/CurrentTime.h	2012-04-05 06:40:16 UTC (rev 113295)
@@ -47,16 +47,8 @@
     return currentTime() * 1000.0;
 }
 
-inline 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
-}
+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.
@@ -66,6 +58,7 @@
 
 using WTF::currentTime;
 using WTF::currentTimeMS;
+using WTF::getCurrentLocalTime;
 using WTF::getLocalTime;
 using WTF::monotonicallyIncreasingTime;
 

Modified: trunk/Source/WebCore/ChangeLog (113294 => 113295)


--- trunk/Source/WebCore/ChangeLog	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/WebCore/ChangeLog	2012-04-05 06:40:16 UTC (rev 113295)
@@ -1,3 +1,18 @@
+2012-04-04  Patrick Gansterer  <[email protected]>
+
+        Add WTF::getCurrentLocalTime()
+        https://bugs.webkit.org/show_bug.cgi?id=83164
+
+        Reviewed by Alexey Proskuryakov.
+
+        Replace the calls to WTF::getLocalTime() with time(0) with the new function.
+        This allows us to use Win32 API on windows to get the same result in a next step.
+
+        * html/FTPDirectoryDocument.cpp:
+        (WebCore::processFileDateString):
+        * loader/archive/mhtml/MHTMLArchive.cpp:
+        (WebCore::MHTMLArchive::generateMHTMLData):
+
 2012-04-04  Hayato Ito  <[email protected]>
 
         Remove ReifiedTreeTraversal.

Modified: trunk/Source/WebCore/html/FTPDirectoryDocument.cpp (113294 => 113295)


--- trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/WebCore/html/FTPDirectoryDocument.cpp	2012-04-05 06:40:16 UTC (rev 113295)
@@ -222,8 +222,7 @@
 
     // If it was today or yesterday, lets just do that - but we have to compare to the current time
     struct tm now;
-    time_t now_t = time(NULL);
-    getLocalTime(&now_t, &now);
+    getCurrentLocalTime(&now);
 
     // localtime does "year = current year - 1900", compensate for that for readability and comparison purposes
     now.tm_year += 1900;

Modified: trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp (113294 => 113295)


--- trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp	2012-04-05 05:29:34 UTC (rev 113294)
+++ trunk/Source/WebCore/loader/archive/mhtml/MHTMLArchive.cpp	2012-04-05 06:40:16 UTC (rev 113295)
@@ -143,11 +143,9 @@
     String boundary = generateRandomBoundary();
     String endOfResourceBoundary = makeString("--", boundary, "\r\n");
 
-    String dateString;
-    time_t localTime = time(0);
     tm localTM;
-    getLocalTime(&localTime, &localTM);
-    dateString = makeRFC2822DateString(localTM.tm_wday, localTM.tm_mday, localTM.tm_mon, 1900 + localTM.tm_year, localTM.tm_hour, localTM.tm_min, localTM.tm_sec, calculateUTCOffset() / (1000 * 60));
+    getCurrentLocalTime(&localTM);
+    String dateString = makeRFC2822DateString(localTM.tm_wday, localTM.tm_mday, localTM.tm_mon, 1900 + localTM.tm_year, localTM.tm_hour, localTM.tm_min, localTM.tm_sec, calculateUTCOffset() / (1000 * 60));
 
     StringBuilder stringBuilder;
     stringBuilder.append("From: <Saved by WebKit>\r\n");
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to