formkit / tempo

📆 Parse, format, manipulate, and internationalize dates and times in JavaScript and TypeScript.
https://tempo.formkit.com
MIT License
2.37k stars 33 forks source link

Feature request: `differenceInMilliseconds` / `differenceInSeconds` / `differenceInMinutes` / etc. #45

Closed Serator closed 7 months ago

Serator commented 8 months ago

Hi and thanks for the great library.

One thing I'm missing is the ability to get the difference between a pair of dates in different units.

Similar function in other libraries:

It would be great to have these functions in Tempo, thanks!

WilcoSp commented 7 months ago

I'll make a PR fork to implement this, but I'll split this into 2 PRs in a stacked PR strategy.

  1. constant
    • milliseconds
    • seconds
    • minutes
    • hours
    • days
    • weeks
  2. variable
    • month
    • year

info about stacking can be found here but in short (feature a = constant & feature b = variable)

afbeelding

it can be decided to merge each separate or both together in 1.