Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Behavior of Moment Differs from Documentation #47

Closed
mitsuhiko opened this issue Dec 7, 2013 · 7 comments
Closed

Behavior of Moment Differs from Documentation #47

mitsuhiko opened this issue Dec 7, 2013 · 7 comments
Milestone

Comments

@mitsuhiko
Copy link

The documentation claims this:

moment.tz("2013-11-18 11:55", "America/Toronto").format();
"2013-11-18T11:55:00-05:00"
moment.tz(new Date(2013, 11, 18), "America/Toronto").format();
"2013-12-18T00:00:00-05:00"

Actual behavior:

moment.tz("2013-11-18 11:55", "America/Toronto").format();
"2013-11-18T06:55:00-05:00"
moment.tz(new Date(2013, 11, 18), "America/Toronto").format();
"2013-12-17T19:00:00-05:00"

It would appear the moment object itself is somehow assuming local time?

@jzernisch
Copy link

Yes, it seems like it interprets the first parameter as local time. For me (sitting in Germany), it is:

moment.tz("2013-11-18 11:55", "America/Toronto").format();
"2013-11-18T05:55:00-05:00"

But if I provide the ISO-formatted UTC time:

moment.tz("2013-11-18T11:55Z", "America/Toronto").format();
"2013-11-18T06:55:00-05:00"

I would also appreciate a more detailed documentation.

@kroo
Copy link
Contributor

kroo commented Jan 15, 2014

This appears to be mostly correct in the latest release (0.0.3). Most timezones seem to behave consistently with documentation now, but I've run into a strange one:

// Reported examples now work as documented (from San Francisco, anyway)
> moment.tz("2013-11-18 11:55", "America/Toronto").format();
'2013-11-18T11:55:00-05:00'
> moment.tz(new Date(2013, 11, 18), "America/Toronto").format();
'2013-12-18T00:00:00-05:00'

// a few other examples
> moment.tz('2014-01-01', 'America/New_York').format()
'2014-01-01T00:00:00-05:00'
> moment.tz('2014-01-01', 'Europe/London').format()
'2014-01-01T00:00:00+00:00'
> moment.tz('2014-01-01 00:00:00', 'Europe/London').format()
'2014-01-01T00:00:00+00:00'

// However, London seems to be off by an hour, once, in 2012:
> moment.tz('2012-10-27', 'Europe/London').format()
'2012-10-27T00:00:00+01:00'
> moment.tz('2012-10-28', 'Europe/London').format()
'2012-10-28T01:00:00+01:00'
> moment.tz('2012-10-29', 'Europe/London').format()
'2012-10-29T00:00:00+00:00'

@jzernisch
Copy link

The last one is just due to daylight saving time. Or what do you find strange here, @kroo?
EDIT: Sorry, misread your post. Yes the 2012-10-28 example is strange.

@tamzinblake
Copy link

Just as a side note, the moment-timezone website still seems to be using an older version, which really confused me trying to test in the console.

@timrwood
Copy link
Member

This is fixed in #93.

@timrwood timrwood added this to the 0.1.0 milestone Jun 18, 2014
@tamzinblake
Copy link

Nice! Thanks

@timrwood
Copy link
Member

This is released in 0.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants