I'm trying to parse and do operations on timestamps such as this one:
"01:46:22,041"
which stands for: 1 hour, 46 minutes, 22 seconds and 41 milliseconds.
I don't really know where to begin here. The existing datatypes all seem to include a date. In my case, I only need to add/substract from the timestamp and then print it out in the same format.
I obviously don't want to write my own calculator if there's one built in. Is there any standard way to tackle this in Haskell?
Use Data.Time.Clock.DiffTime. To parse and format use the functions in Data.Time.Format.
Example:
import Data.Time
xyz :: String -> Maybe DiffTime
xyz x = parseTimeM True defaultTimeLocale "%H:%M:%S" x
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With