Possible bug when using dateString with UTC timezone #26

Open
arnesten opened this Issue Nov 23, 2012 · 2 comments

Comments

Projects
None yet
3 participants
@arnesten

If I do this:

var date  = new time.Date('2012-10-27', 'UTC');
console.log(date.toString());

it prints this:

'Sat Oct 27 2012 02:00:00 GMT+0000 (UTC)'

Notice that the time is 02:00:00. This is the result that I had expected:

'Sat Oct 27 2012 00:00:00 GMT+0000 (UTC)'

If I give '2012-10-27T00:00:00Z' to the constructor it gives the same result. And yes my local timezone at that date is GMT+0200.

Have I misunderstood something or is this a bug?

@TooTallNate

This comment has been minimized.

Show comment Hide comment
@TooTallNate

TooTallNate Jan 31, 2013

Owner

Can you try out the v0.8.4 release and let me know if this is still a problem? Thanks!

Owner

TooTallNate commented Jan 31, 2013

Can you try out the v0.8.4 release and let me know if this is still a problem? Thanks!

@voxpelli

This comment has been minimized.

Show comment Hide comment
@voxpelli

voxpelli Dec 31, 2014

This seems to till happen in v0.11.0 – running the above code in a Node.js file with nothing else in it I get the same result:

'Sat Oct 27 2012 02:00:00 GMT+0000 (UTC)'

If I change the global timezone from my default Europe/Stockholm to UTC before running the time.Date(), by doing time.tzset('UTC');, then the result is instead:

'Sat Oct 27 2012 00:00:00 GMT+0000 (UTC)'

And if I set the global timezone to America/New_York then the result is:

'Fri Oct 26 2012 20:00:00 GMT+0000 (UTC)'

The Date object created always report itself as being in the UTC timezone, but it seems to be converted to UTC after being parsed in the global timezone rather than actually be parsed in the specified timezone as would be expected.

This seems to till happen in v0.11.0 – running the above code in a Node.js file with nothing else in it I get the same result:

'Sat Oct 27 2012 02:00:00 GMT+0000 (UTC)'

If I change the global timezone from my default Europe/Stockholm to UTC before running the time.Date(), by doing time.tzset('UTC');, then the result is instead:

'Sat Oct 27 2012 00:00:00 GMT+0000 (UTC)'

And if I set the global timezone to America/New_York then the result is:

'Fri Oct 26 2012 20:00:00 GMT+0000 (UTC)'

The Date object created always report itself as being in the UTC timezone, but it seems to be converted to UTC after being parsed in the global timezone rather than actually be parsed in the specified timezone as would be expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment