Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

set the timezone explicitly on new time.Date instances

V8 seems to have this strange behavior where the TZ variable is only checked
once for the Date object, and if you change it while V8 is running, then
strange stuff happens:

    > new Date()
    Fri Nov 23 2012 09:54:45 GMT-0800 (PST)
    > time.tzset('UTC')
    > new Date()
    Fri Nov 23 2012 09:54:57 GMT-0800 (UTC)
    > new Date().getTimezoneOffset()
    480

Notice how it *partially* changes over. The timezone abbreviation string
changes correctly, however the internal date of the instance itself is
still incorrectly in PST timezone (-0800). WTF V8...
  • Loading branch information...
commit 21a908200a5b1c6cef6c5df95fcf2c0f5f584803 1 parent d3c6fea
@TooTallNate authored
Showing with 3 additions and 1 deletion.
  1. +2 −0  index.js
  2. +1 −1  package.json
View
2  index.js
@@ -511,6 +511,8 @@ function Date (year, month, day, hour, minute, second, millisecond, timezone) {
// set time given timezone relative to the currently set local time
// (changing the internal "time" milliseconds value unless ms specified)
d.setTimezone(timezone, !(argc == 1 && typeof year === 'number'));
+ } else {
+ d.setTimezone(exports.currentTimezone);
}
return d;
}
View
2  package.json
@@ -13,7 +13,7 @@
],
"main": "./index.js",
"scripts": {
- "test": "TZ=UTC mocha --reporter spec"
+ "test": "mocha --reporter spec"
},
"engines": {
"node": "*"
Please sign in to comment.
Something went wrong with that request. Please try again.