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

Unified Diff: runtime/vm/os_win.cc

Issue 11267051: Updated GetTimeZoneName() to return "" if localtime_r fails or has a NULL for its tm_zone value, li… (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review feedback: added parens, comments. Created 8 years, 2 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 | « runtime/vm/os_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_win.cc
diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc
index 3434ef4dd28f1e59555b13b24c2eab24eaa28dd6..6f3f4c436f05ff3fedd00cad9e270e1857481ccf 100644
--- a/runtime/vm/os_win.cc
+++ b/runtime/vm/os_win.cc
@@ -36,10 +36,14 @@ const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) {
tm decomposed;
// LocalTime will set _tzname.
bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
- ASSERT(succeeded);
- int inDaylightSavingsTime = decomposed.tm_isdst;
- ASSERT(inDaylightSavingsTime == 0 || inDaylightSavingsTime == 1);
- return _tzname[inDaylightSavingsTime];
+ if (succeeded) {
+ int inDaylightSavingsTime = decomposed.tm_isdst;
+ ASSERT(inDaylightSavingsTime == 0 || inDaylightSavingsTime == 1);
+ return _tzname[inDaylightSavingsTime];
+ } else {
+ // Return an empty string like V8 does.
+ return "";
+ }
}
@@ -47,17 +51,21 @@ int OS::GetTimeZoneOffsetInSeconds(int64_t seconds_since_epoch) {
tm decomposed;
// LocalTime will set _timezone.
bool succeeded = LocalTime(seconds_since_epoch, &decomposed);
- ASSERT(succeeded);
- int inDaylightSavingsTime = decomposed.tm_isdst;
- ASSERT(inDaylightSavingsTime == 0 || inDaylightSavingsTime == 1);
- // Dart and Windows disagree on the sign of the bias.
- int offset = static_cast<int>(-_timezone);
- if (inDaylightSavingsTime == 1) {
- static int daylight_bias = GetDaylightSavingBiasInSeconds();
- // Subtract because windows and Dart disagree on the sign.
- offset = offset - daylight_bias;
+ if (succeeded) {
+ int inDaylightSavingsTime = decomposed.tm_isdst;
+ ASSERT(inDaylightSavingsTime == 0 || inDaylightSavingsTime == 1);
+ // Dart and Windows disagree on the sign of the bias.
+ int offset = static_cast<int>(-_timezone);
+ if (inDaylightSavingsTime == 1) {
+ static int daylight_bias = GetDaylightSavingBiasInSeconds();
+ // Subtract because windows and Dart disagree on the sign.
+ offset = offset - daylight_bias;
+ }
+ return offset;
+ } else {
+ // Return zero like V8 does.
+ return 0;
}
- return offset;
}
« no previous file with comments | « runtime/vm/os_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698