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

milliseconds portion is formatted as "1,000" ? #130

Open
mg1075 opened this issue Apr 18, 2019 · 1 comment
Open

milliseconds portion is formatted as "1,000" ? #130

mg1075 opened this issue Apr 18, 2019 · 1 comment

Comments

@mg1075
Copy link

mg1075 commented Apr 18, 2019

What is going on here? Is there a fix or workaround?
moment.duration(3.033333333, "minutes").format("H:mm:ss.SSS");
or
moment.duration(3.033333333, "minutes").format("H:mm:ss.S");

...yield this result:
"3:01.1,000"

And then to confuse the situation further,
moment.duration(3.033333333, "minutes").format("H:mm:ss.SS");
...yields:
"3:01.10"

@jsmreese
Copy link
Owner

jsmreese commented Jul 4, 2019

This is another floating point rounding issue and related to #121.

You'll want to use the precision option in this case:

moment.duration(3.033333333, "minutes").format("H:mm:ss", 1);
"3:02.0"

moment.duration(3.033333333, "minutes").format("H:mm:ss", 2);
"3:02.00"

moment.duration(3.033333333, "minutes").format("H:mm:ss", 3);
"3:02.000"

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

2 participants