Hi all,

Before I raised this as an issue on Node, I wanted to sanity-check it here. 
Basically, I'm having an issue where the Date constructor/localizer lags 
behind a change to process.env.TZ. Here's a script to reproduce what I'm 
seeing:

var assert = require('assert');

// if either of these three lines is commented out, the problem goes away
process.env.TZ = 'America/Los_Angeles';
console.log(new Date().toString());
process.env.TZ = "America/New_York";

// uncomment this and the problem goes away
//console.log(new Date().toString());

// create a date by parsing a string
var d = new Date('2012-1-12 02:00 PM');

// can also create the date this way
//var d = new Date(2012, 0, 12, 14);

// print the date value and locale string
console.log(d.getTime() + " " + d.toLocaleString());

// should create an identical date
var copy = new Date(d);

// print the copy's value and locale string
// the values are the same, but the **strings are different**
console.log(copy.getTime() + " " + copy.toLocaleString());

// here we see the date has been given the wrong value to begin with
assert.equal(d.getTime(), 1326394800000);


Hopefully this makes the problem clear - the script prints two dates with 
identical ms values but differing toString() values. Admittedly, it seems 
harsh to be jerking the TZ around like this, but I suspect there's a bug 
here.

Thanks,
Seth

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to