bug(common): date pipe rounds up date when fractional second is more than 3 digits
See original GitHub issueHi,
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
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 is no limit on the number of decimal places for the decimal fraction https://momentjs.com/docs/#:~:text=Fractional Second https://date-fns.org/v2.14.0/docs/format#:~:text=Fraction of second
🔬 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' }}
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
What are the parameters for the number Pipe - Angular 2
maxFractionDigits is the maximum number of digits after fraction. Defaults to 3. locale is a string defining the locale to use (uses the...
Read more >DatePipe - Angular
Field type Format Description
Era G, GG & GGG Abbreviated
GGGG Wide
GGGGG Narrow
Read more >Date range aggregation | Elasticsearch Guide [8.5] | Elastic
A range aggregation that is dedicated for date values. ... < now minus 10 months, rounded down to the start of the month....
Read more >Angular Date Pipe & formatting dates in Angular with examples
timezone, The default timezone is local system timezone of the user's machine. To change the timezone we can pass timezone offset ('0530') or ......
Read more >as.POSIXlt: Date-time Conversion Functions - Rdrr.io
character string giving a date-time format as used by strptime . ... z <- 1579598122120 op <- options(digits.secs = 3) # avoid rounding...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So I think it would be reasonable to “fix” this, but I think it would count as a breaking change and not be released until 11.0.0
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.