moment / luxon

⏱ A library for working with dates and times in JS
https://moment.github.io/luxon
MIT License
15.12k stars 728 forks source link

Rescale `Duration` with unit #1505

Open Ericlm opened 10 months ago

Ericlm commented 10 months ago

Is your feature request related to a problem? Please describe. I'm often dealing with Duration objects from a number of minutes, and display them as nhours, xminutes, but not in higher unit. I could use the rescale() function, but it doesn't take any unit. Another way would be that the shiftTo function can optionally ignore zero-ed units.

Describe the solution you'd like The ideal option would be that the rescale function could take time units, removing units at 0. Otherwise, it would be great that the shiftTo function had an option to remove zero-ed values.

Describe alternatives you've considered I need to use the shiftTo function with shiftTo('minutes', 'hours'), but it doesn't automatically removes the values at 0, so it can display 0 hours and 20 minutes, or 2 hours and 0 minutes.