module BuildBox.Time
( module Data.Time
, readLocalTimeOfDayAsUTC
, getStampyTime
, getMidnightTodayLocal
, getMidnightTodayUTC
, getMidnightTomorrowLocal
, getMidnightTomorrowUTC)
where
import Data.Time
readLocalTimeOfDayAsUTC :: String -> IO TimeOfDay
readLocalTimeOfDayAsUTC str
= do
curTime <- getZonedTime
let (_, timeOfDayUTC)
= localToUTCTimeOfDay
(zonedTimeZone curTime)
(read str)
return timeOfDayUTC
getStampyTime :: IO String
getStampyTime
= do time <- getZonedTime
return $ formatTime defaultTimeLocale "%0Y%0m%0d_%0k%0M%0S" time
getMidnightTodayLocal :: IO LocalTime
getMidnightTodayLocal
= do curTime <- getZonedTime
return $ LocalTime
{ localDay = localDay $ zonedTimeToLocalTime curTime
, localTimeOfDay = midnight }
getMidnightTodayUTC :: IO UTCTime
getMidnightTodayUTC
= do curTime <- getZonedTime
return $ zonedTimeToUTC
$ ZonedTime
(LocalTime
{ localDay = localDay $ zonedTimeToLocalTime curTime
, localTimeOfDay = midnight })
(zonedTimeZone curTime)
getMidnightTomorrowLocal :: IO LocalTime
getMidnightTomorrowLocal
= do curTime <- getZonedTime
return $ LocalTime
{ localDay = addDays 1 (localDay (zonedTimeToLocalTime curTime))
, localTimeOfDay = midnight }
getMidnightTomorrowUTC :: IO UTCTime
getMidnightTomorrowUTC
= do curTime <- getZonedTime
return $ zonedTimeToUTC
$ ZonedTime
(LocalTime
{ localDay = addDays 1 (localDay (zonedTimeToLocalTime curTime))
, localTimeOfDay = midnight })
(zonedTimeZone curTime)