angular-cn/packages/common/test/pipes
Ajit Singh 26f28200bf fix(common): do not round up fractions of a millisecond in `DatePipe` (#38009)
Currently, the `DatePipe` (via `formatDate()`) rounds fractions of a millisecond to the
nearest millisecond. This can cause dates that are less than a millisecond before midnight
to be incremented to the following day.

The [ECMAScript specification](https://www.ecma-international.org/ecma-262/5.1/#sec-15.9.1.11)
defines that `DateTime` milliseconds should always be rounded down, so that `999.9ms`
becomes `999ms`.

This change brings `formatDate()` and so `DatePipe` inline with the ECMAScript
specification.

Fixes #37989

BREAKING CHANGE:

When passing a date-time formatted string to the `DatePipe` in a format that contains
fractions of a millisecond, the milliseconds will now always be rounded down rather than
to the nearest millisecond.

Most applications will not be affected by this change. If this is not the desired behaviour
then consider pre-processing the string to round the millisecond part before passing
it to the `DatePipe`.

PR Close #38009
2020-09-10 10:55:37 -07:00
..
async_pipe_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
case_conversion_pipes_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
date_pipe_spec.ts fix(common): do not round up fractions of a millisecond in `DatePipe` (#38009) 2020-09-10 10:55:37 -07:00
i18n_plural_pipe_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
i18n_select_pipe_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
json_pipe_spec.ts feat(core): update reference and doc to change `async` to `waitAsync`. (#37583) 2020-08-03 12:54:13 -07:00
keyvalue_pipe_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
number_pipe_spec.ts build: update license headers to reference Google LLC (#37205) 2020-05-26 14:26:58 -04:00
slice_pipe_spec.ts feat(core): update reference and doc to change `async` to `waitAsync`. (#37583) 2020-08-03 12:54:13 -07:00