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

Test failure in diff/1 hour from now #625

Closed
gilles-duboscq opened this issue Feb 12, 2013 · 3 comments
Closed

Test failure in diff/1 hour from now #625

gilles-duboscq opened this issue Feb 12, 2013 · 3 comments

Comments

@gilles-duboscq
Copy link

On Firefox i get an error in the 45.5 test (diff/1 hour from now) :

45.5 1 hour from now = 360000 (3600000 == 3600211)
AssertionError: 1 hour from now = 360000

Date.prototype.toString = Tue Feb 12 2013 16:34:16 GMT+0100 (CET)
Date.prototype.toLocaleString = mar. 12 févr. 2013 16:34:16 CET
Date.prototype.getTimezoneOffset = -60
navigator.userAgent = Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0

I tried multiple times and got different values for the tert failure (3600211, 3600054, 3600661...).
However, when trying in the console, i could not reproduce:

› var oneHourDate = new Date();
‹ undefined
› var nowDate = new Date(oneHourDate);
‹ undefined
› oneHourDate.setHours(oneHourDate.getHours() + 1);
‹ 1360687085471
› moment(oneHourDate).diff(nowDate)
‹ 3600000

or (not that it should make any difference, just to be sure)

› var oneHourDate = new Date(),
          nowDate = new Date(oneHourDate);
‹ undefined
› oneHourDate.setHours(oneHourDate.getHours() + 1);
‹ 1360687403332
› moment(oneHourDate).diff(nowDate)
‹ 3600000
@ichernev
Copy link
Contributor

>>> var z = new Date(), zz = new Date(z);
undefined
>>> z.valueOf()
1360734223263
>>> zz.valueOf()
1360734223000

This is on FF 18.0.1 on Linux. When reading the MDN docs it seems they do not accept a date as an argument to a Date constructor. If you do new Date(otherDate.valueOf()) it works just right. I guess we need to fix the tests :)

@pascon
Copy link

pascon commented Feb 13, 2013

Hi, the same here - I only ran tests from the Moment site.

Environment:

Date.prototype.toString = Wed Feb 13 2013 09:52:56 GMT+0100 (Central European Standard Time)
Date.prototype.toLocaleString = 13 luty 2013 09:52:56
Date.prototype.getTimezoneOffset = -60
navigator.userAgent = Mozilla/5.0 (Windows NT 6.1; WOW64; rv:18.0) Gecko/20100101 Firefox/18.0

Test:

45.5 1 hour from now = 360000 (3600000 == 3600879)

AssertionError: 1 hour from now = 360000

This was referenced Feb 20, 2013
@ichernev
Copy link
Contributor

This is fixed now, closing.

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

3 participants