How can I extract specific time components out of a UTCTime?
haskell
Solution
A `UTCTime` has two components: a day and a `DiffTime`. You can get the `DiffTime` using `utctDayTime` or by pattern matching. From there, you can convert it to a `TimeOfDay` using `timeToTimeOfDay`. You can then just pattern match against the `TimeOfDay` to get the hours, minutes and seconds.
So you could do this:
let TimeOfDay hours minutes seconds = timeToTimeOfDay (utctDayTime time)
You can also use the `todMin` and `todSec` functions to get the minutes and seconds respectively out of the `TimeOfDay`.
Problem
If I have this code: `let time = read "2013-02-03 17:00:07.687" :: UTCTime` How can I extract the minutes and seconds components out of the `UTCTime`?