Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Math.ceil way in differenceInMinutes #683

Closed
hongbo-miao opened this issue Feb 10, 2018 · 1 comment
Closed

Math.ceil way in differenceInMinutes #683

hongbo-miao opened this issue Feb 10, 2018 · 1 comment

Comments

@hongbo-miao
Copy link

I am trying to build a countdown. However, I realized differenceInMinutes is similar to Math.floor.

    // return 0 which is expected
    const min1 = differenceInMinutes(
      new Date(2014, 6, 2, 12, 20, 0),
      new Date(2014, 6, 2, 12, 20, 0)
    );

    // return 0, however I hope it return 1
    const min2 = differenceInMinutes(
      new Date(2014, 6, 2, 12, 20, 0),
      new Date(2014, 6, 2, 12, 19, 59)
    );

It would be great to support Math.ceil way too.

@fturmel
Copy link
Member

fturmel commented Dec 2, 2021

Hi @hongbo-miao,

Thanks for your suggestion! Since v2.24, difference* functions have a roundingMethod option which should address this request (see #2571)

https://date-fns.org/v2.27.0/docs/differenceInMinutes

@fturmel fturmel closed this as completed Dec 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants