Skip to content
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
@arshmakker

Description

@arshmakker

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions