TooTallNate/node-time

node-time influences native Date timezone

Opened this issue · 0 comments

I have a server set to UTC time. First I run this:

var time = require('time');

var date  = new Date('2015-03-27');
console.log(date);
new time.Date().setTimezone('Asia/Shanghai');
console.log(date);

Output:

Fri Mar 27 2015 00:00:00 GMT+0000 (UTC)
Fri Mar 27 2015 00:00:00 GMT+0000 (UTC)

So far so good. Now I skip the first console.log:

var time = require('time');

var date  = new Date('2015-03-27');
//console.log(date);
new time.Date().setTimezone('Asia/Shanghai');
console.log(date);

Output:

Fri Mar 27 2015 08:00:00 GMT+0800 (CST)

Suddenly the date has a different timezone. The new time.Date() bit shouldn't really influence the date variable. As to why a console.log stops the bug, I have no idea.

node-time version: 0.11.1
node version: v0.10.33
OS: Amazon Linux