I want to parse and print durations in the format
"HH:MM:SS.sss". Parsing seems to be pretty simple. if I do for example
julia> str = "1:02:23.234" "1:02:23.234" julia> t = Time(str) 01:02:23.234
this seems to work just fine. However, this is not a
TimePeriod but a time.
If I want to go the other way and print
TimePeriods in that format I’m running into problems:
julia> Dates.format(Time(Second(32)), "HH:MM:SS.sss") "00:00:32.000"
works fine but
julia> Dates.format(Time(Second(432)), "HH:MM:SS.sss") ERROR: ArgumentError: Second: 432 out of range (0:59)
throws an error.
Dates.format does not take
TimePeriods for an argument:
julia> Dates.format(Second(432), "HH:MM:SS.sss") ERROR: MethodError: no method matching format(::Second, ::String)
CompoundPeriods also does not work:
julia> d = Minute(2) + Second(10) 2 minutes, 10 seconds julia> Dates.format(Time(d), "HH:MM:SS.sss") ERROR: MethodError: no method matching Int64(::Dates.CompoundPeriod)
Does anyone know if there’s a built in way to print my duration in the desired format, is there any package that deals with this, or do I have to write a custom function?