Skip to content
This repository has been archived by the owner on Jul 10, 2019. It is now read-only.

Days diffs are calculated based on the beginning of the day #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fracmak
Copy link

@fracmak fracmak commented Oct 27, 2017

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'

@yahoocla
Copy link

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! 😄

@sdwvit
Copy link

sdwvit commented Dec 19, 2017

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

@caridy
Copy link
Collaborator

caridy commented Dec 21, 2017

It is a little more complicated that just this, read tc39/proposal-intl-relative-time#9 for more details.

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 this pull request may close these issues.

Rounding of in the diff is causing a half a day loss
4 participants