Use correct timezone information on Solaris
authoryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Oct 2012 13:04:05 +0000 (13:04 +0000)
committeryangguo@chromium.org <yangguo@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 23 Oct 2012 13:04:05 +0000 (13:04 +0000)
`timezone` variable contains the difference, in seconds, between UTC and
local standard time (see `man 3 localtime` on Solaris).

Call to `tzset` is required to apply contents of `TZ` variable to
`timezone` variable.

BUG=v8:2064

Review URL: https://chromiumcodereview.appspot.com/10967066
Patch from Maciej MaƂecki <me@mmalecki.com>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12802 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/platform-solaris.cc

index ed9786e..5652741 100644 (file)
@@ -125,12 +125,8 @@ const char* OS::LocalTimezone(double time) {
 
 
 double OS::LocalTimeOffset() {
-  // On Solaris, struct tm does not contain a tm_gmtoff field.
-  time_t utc = time(NULL);
-  ASSERT(utc != -1);
-  struct tm* loc = localtime(&utc);
-  ASSERT(loc != NULL);
-  return static_cast<double>((mktime(loc) - utc) * msPerSecond);
+  tzset();
+  return -static_cast<double>(timezone * msPerSecond);
 }