module Time.System
(
timeCurrent
, timeCurrentP
, dateCurrent
, localDateCurrent
, localDateCurrentAt
, timezoneCurrent
) where
import Control.Applicative
import Time.Types
import Data.Hourglass.Time
import Data.Hourglass.Local
import Data.Hourglass.Internal (systemGetElapsedP, systemGetElapsed, systemGetTimezone)
timeCurrent :: IO Elapsed
timeCurrent = systemGetElapsed
timeCurrentP :: IO ElapsedP
timeCurrentP = systemGetElapsedP
dateCurrent :: IO DateTime
dateCurrent = timeGetDateTimeOfDay <$> timeCurrentP
localDateCurrent :: IO (LocalTime DateTime)
localDateCurrent = localTimeSetTimezone <$> timezoneCurrent
<*> (localTimeFromGlobal <$> dateCurrent)
localDateCurrentAt :: TimezoneOffset -> IO (LocalTime DateTime)
localDateCurrentAt tz = localTimeSetTimezone tz . localTimeFromGlobal <$> dateCurrent
timezoneCurrent :: IO TimezoneOffset
timezoneCurrent = systemGetTimezone