cleave-zen icon indicating copy to clipboard operation
cleave-zen copied to clipboard

Duration input with Cleave-zen

Open MakingOff opened this issue 1 year ago • 1 comments

Hey!

I'm in a situation where users must be able to input a duration in the following format: HH'h'MM, (47h30). With HH between 0 and 99 and MM between 0 and 59 (like real minutes would be). Obviously, I can't use formatTime, I'd only be able to get 23h max. Nor can I use formatGeneral with blocks: [2, 2], because users could input more than 59 minutes.

So I'm wondering if there's a way to do this? Or if something could be implemented to make this possible?

Thank you!

MakingOff avatar May 16 '24 09:05 MakingOff

This can be kind of supported with formatTime(value, { delimiters: ['h'], timePattern: ['x', 'm'], }) (and by ignorign the error)

I made a fork where this is explicitly supported with

formatTime(value, {
      delimiters: ['h'],
      timePattern: ['xx', 'm'], // number of x = number of digits
    })

wyozi avatar Aug 11 '24 09:08 wyozi