This repository was archived by the owner on Jul 10, 2019. It is now read-only.
This repository was archived by the owner on Jul 10, 2019. It is now read-only.
Rounding of in the diff is causing a half a day loss #52
Closed
Description
Hi,
We are using react-intl intensively for internationalization. React-intl is internally using intl-relativeformat for calculating 'today' and 'yesterday'.
Intl-relativeformate incorrectly shows 'today' even if the datetime send to it was from yesterday for the following times.
Time Sent | Current Time | Relative |
---|---|---|
2017-09-06T18:29:30.314143+00:00 | 2017-09-067T04:29:30.314143+00:00 | Today |
2017-09-06T18:00:30.314143+00:00 | 2017-09-067T04:09:30.314143+00:00 | Today |
The code that I am talking about is:
file name : intl-relativeformat/src/diff.js
------------
var millisecond = round(to - from),
second = round(millisecond / 1000),
minute = round(second / 60),
hour = round(minute / 60),
day = round(hour / 24),
week = round(day / 7);
---------------
The issue can be easily solved by replacing the code with the below code
var millisecond = to - from,
second = millisecond / 1000,
minute = second / 60,
hour = minute / 60,
day = round(hour / 24),
week = round(day / 7);
Regards
Arsh
Metadata
Metadata
Assignees
Labels
No labels