-
Notifications
You must be signed in to change notification settings - Fork 103
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
Consider adding parsing and formatting support for kotlin.time.Duration
#348
Comments
I would like this. I display durations in console output, reports, and compose GUIs often in similar places to where I display dates, so it would be nice to have similar formatting options. I also could use this to make a custom parser for a duration input component in compose. |
@mgroth0, thanks! Could you share some examples of the |
Sure! One example is for a stopwatch component, which displays the time an operation has been running. The string is guaranteed to be N characters long (I have N at 18).
It works but it also feels a little messy and I'm not sure if this is the best approach. One nice thing about having the library have first class support for this sort of thing is it helps me figure out the best way to do it. And that would only work for formatting an existing value. Parsing would be a whole different animal and I guess it might not work with this sort of format. |
Another format I have is very similar, but is designed for text to speech so it uses the full unit names instead of the abbreviations, and doesn't care about padding. The other feature I have in mind is one that I haven't developed yet, but it would allow users to type an arbitrary duration into a text field and it would be parsed into a Duration value. |
Hm. I don't think that What your code could certainly benefit from is some way to conveniently format numbers, so |
Even though it's not strictly part of this library, it could still benefit from
DateTimeFormat
formatting capabilities. Please share your use cases and suggestions here.The text was updated successfully, but these errors were encountered: