Skip to content

DatePipe does not Round 99.5 to 99.9 Milliseconds correctly #24384

Closed

Description

@jmgrill

[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
[ ] Other... Please describe:

Current behavior

The angular date pipe rounds the milisecond portion of the format without allowing a round upward from 99 to 100 to increase the the value in the second's position, producing both the wrong value and the wrong number of digits in the formatted output.

{{3999 | date:'m:ss.SS'}} ----> 0:03.100

reproduced here:
https://stackblitz.com/edit/angular-nc4d3n?file=src%2Fapp%2Fapp.component.html

Expected behavior

{{3999 | date:'m:ss'}} ----> 0:03
{{3999 | date:'m:ss.S'}} ----> 0:03.9
{{3999 | date:'m:ss.SS'}} ----> 0:03.99
{{3999 | date:'m:ss.SSS'}} ----> 0:03.999
(edit by vicb)

Minimal reproduction of the problem with instructions

{{3999 | date:'m:ss.SS'}} ----> 0:03.100

reproduced here:
https://stackblitz.com/edit/angular-nc4d3n?file=src%2Fapp%2Fapp.component.html

What is the motivation / use case for changing the behavior?

The date pipe does not format timestamps correctly, which is something that I'd imagine plenty of people want to use it for.

Activity

  1. dawidgarus commented on Jun 8, 2018

    @dawidgarus

    Although 0:03.100 is wrong, DatePipe should be used to display date, not time intervals and in my opinion it should not be rounded. For example, 2018-06-08T23:59:59.999 should not be rounded to 2018-06-09T00:00:00.00 in any circumstance.

  2. added
    area: commonIssues related to APIs in the @angular/common package
    area: i18nIssues related to localization and internationalization
    on Jun 8, 2018
  3. added this to the needsTriage milestone on Jun 8, 2018
  4. jmgrill commented on Jun 11, 2018

    @jmgrill
    Author

    I agree with both comments above.

  5. modified the milestones: needsTriage, Backlog on Jul 10, 2018
  6. added a commit that references this issue on Jul 11, 2018
    69b1819
  7. added a commit that references this issue on Jul 11, 2018
    0746485
  8. added 2 commits that reference this issue on Jul 30, 2018
    5399c17
  9. angular-automatic-lock-bot commented on Sep 13, 2019

    @angular-automatic-lock-bot

    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.

  10. locked and limited conversation to collaborators on Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: commonIssues related to APIs in the @angular/common packagearea: i18nIssues related to localization and internationalizationfreq1: lowtype: bug/fix

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions