Skip to content
This repository has been 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
arshmakker opened this issue Sep 9, 2017 · 1 comment · May be fixed by #57
Closed

Rounding of in the diff is causing a half a day loss #52

arshmakker opened this issue Sep 9, 2017 · 1 comment · May be fixed by #57

Comments

@arshmakker
Copy link

arshmakker commented Sep 9, 2017

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

himanshuara pushed a commit to himanshuara/intl-relativeformat that referenced this issue Sep 11, 2017
himanshuara pushed a commit to himanshuara/react-intl that referenced this issue Sep 11, 2017
himanshuara pushed a commit to himanshuara/react-intl that referenced this issue Sep 11, 2017
himanshuara pushed a commit to himanshuara/intl-relativeformat that referenced this issue Sep 11, 2017
fracmak added a commit to fracmak/intl-relativeformat that referenced this issue Oct 27, 2017
fracmak added a commit to fracmak/intl-relativeformat that referenced this issue Oct 27, 2017
@longlho
Copy link
Member

longlho commented Jun 8, 2019

fixed in latest intl-relativeformat

@longlho longlho closed this as completed Jun 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants