Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: src/core/SkTime.cpp

Issue 1562943002: SkTime: Stop using POSIX entensions to time.h for timezone (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 2016-01-11 (Monday) 17:28:49 EST Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/animator/SkTime.cpp ('k') | src/ports/SkTime_Unix.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTime.cpp
diff --git a/src/core/SkTime.cpp b/src/core/SkTime.cpp
index 86a0685c70af27703490024f15bf80ff5aef5152..5b596e7a6d4f2dfd0b0e7f06fe4c9e7c3832b7fc 100644
--- a/src/core/SkTime.cpp
+++ b/src/core/SkTime.cpp
@@ -8,6 +8,7 @@
#include "SkOncePtr.h"
#include "SkString.h"
#include "SkTime.h"
+#include "SkTypes.h"
void SkTime::DateTime::toISO8601(SkString* dst) const {
if (dst) {
@@ -24,6 +25,46 @@ void SkTime::DateTime::toISO8601(SkString* dst) const {
}
}
+
+#ifdef SK_BUILD_FOR_WIN32
+
+#include "Windows.h"
+void SkTime::GetDateTime(DateTime* dt) {
+ if (dt) {
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+ dt->fTimeZoneMinutes = 0;
+ dt->fYear = st.wYear;
+ dt->fMonth = SkToU8(st.wMonth);
+ dt->fDayOfWeek = SkToU8(st.wDayOfWeek);
+ dt->fDay = SkToU8(st.wDay);
+ dt->fHour = SkToU8(st.wHour);
+ dt->fMinute = SkToU8(st.wMinute);
+ dt->fSecond = SkToU8(st.wSecond);
+ }
+}
+
+#else // SK_BUILD_FOR_WIN32
+
+#include <time.h>
+void SkTime::GetDateTime(DateTime* dt) {
+ if (dt) {
+ time_t m_time;
+ time(&m_time);
+ struct tm* tstruct;
+ tstruct = gmtime(&m_time);
+ dt->fTimeZoneMinutes = 0;
+ dt->fYear = tstruct->tm_year + 1900;
+ dt->fMonth = SkToU8(tstruct->tm_mon + 1);
+ dt->fDayOfWeek = SkToU8(tstruct->tm_wday);
+ dt->fDay = SkToU8(tstruct->tm_mday);
+ dt->fHour = SkToU8(tstruct->tm_hour);
+ dt->fMinute = SkToU8(tstruct->tm_min);
+ dt->fSecond = SkToU8(tstruct->tm_sec);
+ }
+}
+#endif // SK_BUILD_FOR_WIN32
+
#if defined(_MSC_VER)
// TODO: try std::chrono again with MSVC 2015?
#include <intrin.h>
« no previous file with comments | « src/animator/SkTime.cpp ('k') | src/ports/SkTime_Unix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698