question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug(common): date pipe rounds up date when fractional second is more than 3 digits

See original GitHub issue

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

https://github.com/angular/angular/blob/d1ea1f4c7f3358b730b0d94e65b00bc28cae279c/packages/common/src/i18n/format_date.ts#L735

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:closed
  • Created 3 years ago
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

5reactions
petebacondarwincommented, Jul 9, 2020

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

0reactions
angular-automatic-lock-bot[bot]commented, Oct 11, 2020

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found