jiffy
jiffy copied to clipboard
Is there a way to get a difference between dates without specifying units?
Is your feature request related to a problem? Please describe. Jiffy({ "year": 2007, "month": 1, "day": 28 }).diff([2017, 1, 29], Units.DAY); // 1
I would like to have a difference method that would choose the most logical units without me having to specify it.
Describe the solution you'd like For example:
- Difference is 0.3 minutes => would display 18 seconds
- Difference is 61 minutes => would display 1 hour and 1 minute
- Difference is 26h42mins => would display 1 day, 2 hours and 42 minutes
Describe alternatives you've considered The only alternative right now that I can see is the relative time methods, but I don't want the "ago" suffix.
This would be very useful, in my opinion, for when you want to display the time something took to do, when you have the initial timestamp and the ending timestamp and want to see the difference between the two.
Thank you.
@MiguelSOliveira This feature is not available in Jiffy, but will be cool to add it.
Do you have any ideas
Off the top of my head, it may be possible to retrieve the object as a string using toString() and then doing a split() on the string. Maybe that will work. You could refer to this link:
https://github.com/jama5262/jiffy/pull/218