intl-relativeformat icon indicating copy to clipboard operation
intl-relativeformat copied to clipboard

Days diffs are calculated based on the beginning of the day

Open fracmak opened this issue 8 years ago • 3 comments

Fixes #52

Because day diffs are calculated based on the time between the from and to day, rounded up or down, you could end up saying one day is "yesterday" when it really occurred 12 hours ago on the same day. To fix this we normalize the days to midnight in the current locale and then convert it into milliseconds to calculate the difference in days.

Test included to show that diff between midnight and 1 second before midnight should result in 'yesterday'

fracmak avatar Oct 27 '17 16:10 fracmak

Thank you for submitting this pull request, however I do not see a valid CLA on file for you. Before we can merge this request please visit https://yahoocla.herokuapp.com/ and agree to the terms. Thanks! :smile:

yahoocla avatar Oct 27 '17 16:10 yahoocla

@okuryu pls review & merge, this is critical for business

sdwvit avatar Dec 19 '17 15:12 sdwvit

It is a little more complicated that just this, read https://github.com/tc39/proposal-intl-relative-time/issues/9 for more details.

caridy avatar Dec 21 '17 15:12 caridy