Repository navigation
Enhance ISO date parsing with proper millisecond rounding - #1978
Conversation
|
Thanks for the feedback @rbri! I've added comprehensive test cases for overflow handling:
The tests validate all the overflow code paths in the implementation. Ready for another review! |
|
Thanks - see my comment below |
|
Have done some more tests with real browsers -> looks like there is no rounding and also there is no overflow I think our impl should match the browser behavior. |
|
you can also use to check there is no rounding |
|
So you do y'all want to proceed with this? I like the idea of proper rounding, but I also like being consistent with browsers, and it sounds like test262 doesn't really have anything that can help us here. |
|
From a quick reading of the spec, there is no hint about rounding, the described behavior looks like it always lead to ignoring. |
|
Thank you @rbri and @gbrail for the thorough review and testing. After researching this further, I realize I may have overcomplicated the solution. The original issue #1223 simply asks for Rhino to parse ISO date strings with >3 digit milliseconds (like other engines do), not to implement specific rounding behavior. Your testing confirms I see three options:
For context, high-precision timestamps are common in:
The ability to parse these without throwing an error would help Rhino users working with such systems, even if we truncate to millisecond precision. What would you prefer? I'm happy to simplify the implementation to match browser behavior while solving the original parsing issue. |
|
Thanks @anivar for your detailed description of possible steps forward. I personally have a clear preference - i like to see version one. Rhino should simply behave like the other js engines around. Will be great if you can change the PR to support and test this. |
- Replace truncation with mathematical rounding for >3 digit milliseconds - Handle overflow cases (e.g., 999.9ms -> 1000.0ms) - Maintain full backward compatibility for existing formats - Add comprehensive test coverage for rounding behavior Fixes mozilla#1223: Support parsing ISO date strings with millisecond precision > 3 digits
- Test millisecond overflow (999.5ms -> 1000ms -> next second) - Test cascading overflow (59.9995s -> next minute) - Test day boundary overflow (23:59:59.9995 -> next day) - Address rbri's review: validates all overflow code paths
Added missing @test annotations for ctorDateTimeMillisecondsOnlyTwoDigitsPlus() and ctorDateTimeMillisecondsOnlyTwoDigitsMinus() test methods. These methods were not being executed during test runs, causing the GitHub Actions build to fail.
Remove trailing whitespace to comply with Spotless formatting requirements.
…rounding - Remove complex rounding logic - Simply truncate to first 3 millisecond digits - Update tests to verify truncation behavior - Matches Chrome, Firefox, Safari behavior
8ab328b to
5f35317
Compare
|
LGTM. I'm going to squash these and update the message to indicate what you actually did. Thanks! |
Summary
Enhances ISO date parsing to use proper mathematical rounding instead of truncation for millisecond precision greater than 3 digits.
Changes
Test Results
All existing tests pass
New rounding tests pass
Manual verification confirms expected behavior:
Implementation Details
Fixes
Closes #1223