cdornan / fmt

New formatting library
BSD 3-Clause "New" or "Revised" License
56 stars 6 forks source link

Add duration formatter #12

Closed chshersh closed 3 years ago

chshersh commented 6 years ago

I would really appreciate some formatter for ranges like 1w2d3h4m like this one:

durationF :: Natural -> Builder

But I would like to have an ability to easily interpret 9623 as 9623 minutes or 9623 seconds and format in either 160h23m or 160m23s. Dunno how the resulting interface should look like...

chshersh commented 6 years ago

Seems relevant:

neongreen commented 6 years ago

There's diffF already but I agree that we should have something like this.

neongreen commented 6 years ago

Though obviously baking-in 8 hour days won't be good

neongreen commented 6 years ago

Maybe we can indeed use the o-clock idea with series. I think that instead of type-level lists we can just have a list of predefined (Builder, Int) pairs. @ChShersh what do you think?

chshersh commented 6 years ago

@neongreen Well, since there's o-clock I don't actually need durationF formatter anymore. seriesF is enough to me. I won't use this formatter on something that doesn't represent time. And if I need time I probably will use o-clock. seriesF is already a good reason for me to use package like o-clock. Though, o-clock probably should have Buildable instance but at this moment it's not clear for me which exact Buildable should it use...

cdornan commented 3 years ago

It looks like we don't need this — please feel free to reopen if you disagree.