-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Description
Hi,
I believe I've come across a bug in the date parsing.
I haven't seen any indications that this is expected behavior, so I'm opening an issue here.
🐞 bug report
Affected Package
@angular/common
Seems to be in every version I tested. Angular 6, 9, 10
const ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000); |
Is this a regression?
Not that I've seen.
Description
The Date pipe has some unexpected behavior when second fractions have more than 3 digits.
ISO 8601 format is not capped on fractional second number of digits.
https://www.w3.org/TR/NOTE-datetime
https://en.wikipedia.org/wiki/ISO_8601#:~:text=There%20is%20no%20limit%20on%20the%20number%20of%20decimal%20places%20for%20the%20decimal%20fraction
https://momentjs.com/docs/#:~:text=Fractional%20Second
https://date-fns.org/v2.14.0/docs/format#:~:text=Fraction%20of%20second
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-date-fractional-second-test
3 digits: {{ '2020-08-01T23:59:59.999' | date: 'yyyy-MM-dd' }}
<br>
4 digits: {{ '2020-08-01T23:59:59.9999' | date: 'yyyy-MM-dd' }}