Print NominalDiffTime as hours, minutes and seconds
You can print a DiffTime
-- which actually represents a duration, and is likely the type you should be using -- by going through TimeOfDay
. Getting your hands on a DiffTime
correctly is actually a little bit tricky; you'll need:
- A leap second table. type documentation, a page with a leap second table; you'll want to have a way for your program to read this in at runtime, as these change every few months.
- From there, you can use
utcToTAITime
to convert toAbsoluteTime
, and diffAbsoluteTime
to get aDiffTime
, andtimeToTimeOfDay
to have the library do your divmod's for you, and finallyformatTime
to print this.