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

Duration asMilliseconds regression from v2.6.0 to v2.8.1 #1867

Closed
mjgallag opened this issue Aug 18, 2014 · 3 comments
Closed

Duration asMilliseconds regression from v2.6.0 to v2.8.1 #1867

mjgallag opened this issue Aug 18, 2014 · 3 comments
Labels
Milestone

Comments

@mjgallag
Copy link

moment.duration({minutes: 17, seconds: 25, milliseconds: 900}).asMilliseconds();
1045900 //v2.60
1045899.9999999999 //v2.8.1

@ichernev ichernev added the Bug label Aug 20, 2014
@ichernev
Copy link
Contributor

You're right. The regression is in 2.7.0 to 2.8.1. We reimplemented duration, and evidently this thing slipped :)

@ichernev ichernev added this to the 2.8.3 milestone Aug 22, 2014
@jsmreese
Copy link

The breaking change came in version 2.8.0, and it affects the .as() and .asUnits() methods for the units 'milliseconds', 'seconds', and 'minutes'.

The updated .as() implementation leads to floating point errors for those units.

Simple tests, that should be true:

moment.duration(1, "milliseconds").as("milliseconds") === 1;
moment.duration(3, "seconds").as("seconds") === 3;
moment.duration(13, "minutes").as("minutes") === 13;

@ichernev
Copy link
Contributor

ichernev commented Sep 5, 2014

Closing in favor of #1883

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

Successfully merging a pull request may close this issue.

3 participants