Index: runtime/vm/os_win.cc |
diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc |
index 2acef13fe304b92e735082d851fb144e2524bd51..076eb4c083c3eb45f91ffbcb72c933bd415aa95f 100644 |
--- a/runtime/vm/os_win.cc |
+++ b/runtime/vm/os_win.cc |
@@ -7,6 +7,7 @@ |
#include <time.h> |
#include "platform/assert.h" |
+#include "vm/thread.h" |
Ivan Posva
2012/04/11 12:01:24
ditto
floitsch
2012/04/11 12:10:21
Done.
|
namespace dart { |
@@ -18,9 +19,6 @@ bool OS::BreakDownSecondsSinceEpoch(time_t seconds_since_epoch, |
if (in_utc) { |
error_code = gmtime_s(&tm_result, &seconds_since_epoch); |
} else { |
- // TODO(floitsch): we should be able to call tzset only once during |
- // initialization. |
- tzset(); // Make sure the libc knows about the local zone. |
error_code = localtime_s(&tm_result, &seconds_since_epoch); |
} |
result->year = tm_result.tm_year; |
@@ -46,25 +44,19 @@ bool OS::BrokenDownToSecondsSinceEpoch( |
// Set wday to an impossible day, so that we can catch bad input. |
tm_broken_down.tm_wday = -1; |
// Make sure the libc knows about the local zone. |
- // In case of 'in_utc' this call is mainly for multi-threading issues. If |
- // another thread uses a time-function it will set the timezone. The timezone |
- // adjustement below would then not work anymore. |
// TODO(floitsch): we should be able to call tzset only once during |
// initialization. |
tzset(); |
if (in_utc) { |
// Disable daylight saving in utc mode. |
tm_broken_down.tm_isdst = 0; |
- // mktime assumes that the given date is local time zone. |
- *result = mktime(&tm_broken_down); |
- // Remove the timezone. |
- *result -= timezone; |
+ *result = _mkgmtime(&tm_broken_down); |
} else { |
// Let libc figure out if daylight saving is active. |
tm_broken_down.tm_isdst = -1; |
*result = mktime(&tm_broken_down); |
} |
- if ((*result == -1) && (tm_broken_down.tm_wday == -1)) { |
+ if ((*result == -1 || *result == 1) && (tm_broken_down.tm_wday == -1)) { |
return false; |
} |
return true; |