summaryrefslogtreecommitdiff
path: root/Source/WTF/wtf/GregorianDateTime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WTF/wtf/GregorianDateTime.cpp')
-rw-r--r--Source/WTF/wtf/GregorianDateTime.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/Source/WTF/wtf/GregorianDateTime.cpp b/Source/WTF/wtf/GregorianDateTime.cpp
index 5560984e6..d6317b308 100644
--- a/Source/WTF/wtf/GregorianDateTime.cpp
+++ b/Source/WTF/wtf/GregorianDateTime.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Patrick Gansterer <paroga@paroga.com>
+ * Copyright (C) 2012, 2014 Patrick Gansterer <paroga@paroga.com>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -43,13 +43,16 @@ void GregorianDateTime::setToCurrentLocalTime()
TIME_ZONE_INFORMATION timeZoneInformation;
DWORD timeZoneId = GetTimeZoneInformation(&timeZoneInformation);
- LONG bias = timeZoneInformation.Bias;
- if (timeZoneId == TIME_ZONE_ID_DAYLIGHT)
- bias += timeZoneInformation.DaylightBias;
- else if (timeZoneId == TIME_ZONE_ID_STANDARD)
- bias += timeZoneInformation.StandardBias;
- else
- ASSERT(timeZoneId == TIME_ZONE_ID_UNKNOWN);
+ LONG bias = 0;
+ if (timeZoneId != TIME_ZONE_ID_INVALID) {
+ bias = timeZoneInformation.Bias;
+ if (timeZoneId == TIME_ZONE_ID_DAYLIGHT)
+ bias += timeZoneInformation.DaylightBias;
+ else if ((timeZoneId == TIME_ZONE_ID_STANDARD) || (timeZoneId == TIME_ZONE_ID_UNKNOWN))
+ bias += timeZoneInformation.StandardBias;
+ else
+ ASSERT(0);
+ }
m_year = systemTime.wYear;
m_month = systemTime.wMonth - 1;
@@ -64,7 +67,11 @@ void GregorianDateTime::setToCurrentLocalTime()
#else
tm localTM;
time_t localTime = time(0);
+#if HAVE(LOCALTIME_R)
localtime_r(&localTime, &localTM);
+#else
+ localtime_s(&localTime, &localTM);
+#endif
m_year = localTM.tm_year + 1900;
m_month = localTM.tm_mon;