-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
hh:mm:ss formatting bug #2560
Comments
https://github.com/SheetJS/ssf/blob/71f827c4faa89475996acb2458161bac2bbd4280/ssf.js#L664-L693 The only logic I am having trouble with is why the hour or minute values are only given a chance to round up in the case that a lesser time increment does not exist. for example if the format is |
@phillipperalez There's a grammar for the format string but the specifications don't actually explain how Excel converts a value to a specific type. Excel's time behavior behavior, at least based on when we last looked into it with Excel 2010/2011, is dependent on the specifiers in the format (so rounding when the finest time unit is P.S.: NodeJS module ships with an $ npm install -g ssf
$ ssf "hh:mm:ss" 0.001388773
0.001388773|00:01:00| and you can also test in the browser at http://oss.sheetjs.com/ssf/ |
The rounding algorithm needs to be rethought. Basically if you round the uS, then you need to carry that rounding all the way across, so it's better to just punt and call parse_date_code again with the adjusted time. You're also double-rounding in the [ss].000 case. Here are some failing test cases: mm/dd/yyyy hh:mm:ss.000, 4018.99999998843 = 12/31/1910 23:59:59.999 (correct) |
See: SheetJS#2560 - Improved rounding to account for minutes, hours, etc. - Added tests for rounding dates/times
when time is of a value that should round up the minute, if the second has a u (rounding value I assume) greater than or equal to .5, then the seconds will go to
00
without bumping the minute value up one. In excel the time is properly roundedIn this example I am using
require('make-runnable')
at the end ofssf.js
to test this via CLI. The value is from 119.99 / 86400 - so the result I expect should be 00:02:00, however I receive 00:01:00 insteadnode ssf.js format hh:mm:ss 0.001388773
The text was updated successfully, but these errors were encountered: