You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
moment.duration(1,"minutes").humanize();// a minutemoment.duration(2,"minutes").humanize();// 2 minutesmoment.duration(24,"hours").humanize();// a day
I've found myself wanting to turn an IsoDuration into a string. I'm not sure if that would belong in this library or not, as it seems tricky to specify the output format, as I haven't seen a similar specification like date's "YYYY". I imagine one way to implement this is like:
formatDuration:: { biggestFirst::Boolean, ... } ->Duration->String-- It might be better to move the unit conversion into a separate function.msFromDuration::Duration->MillisecondsformatMS:: { fitToBiggestUnit::Boolean, forceToUnit::DurationComponent } ->Milliseconds->String-- I imagine would need a way to customize this for a locale.newtypeFormatDurationLocale :: FormatDurationLocale (DurationComponent->String)
formatMS::FormatDurationLocale->FormatDurationOpts->Milliseconds->String-- Test it out-- > formatMS englishDurationLocale defaultDurationOpts { fitToBiggest = true } (msFromDuration tenMinutes)-- 10 minutes-- > formatMS (^ same as that ^) (msFromDuration tenDaysTenMinutes)-- 1 week, 3 days, 10 minutes-- > formatMS (englishDurationLocale defaultDurationOpts { forceToUnit = Week }) (msFromDuration tenDaysTenMinutes)-- 1.31 weeks
Have you guys thought about this? Looks like current formatting is only to-from the ISO-8601 duration format.
The text was updated successfully, but these errors were encountered:
MomentJS has a way to turn a duration into a human-readable string:
https://momentjs.com/docs/#/durations/humanize/
I've found myself wanting to turn an IsoDuration into a string. I'm not sure if that would belong in this library or not, as it seems tricky to specify the output format, as I haven't seen a similar specification like date's "YYYY". I imagine one way to implement this is like:
Have you guys thought about this? Looks like current formatting is only to-from the ISO-8601 duration format.
The text was updated successfully, but these errors were encountered: