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 :: IO Elapsed
timeCurrent = IO Elapsed
systemGetElapsed
timeCurrentP :: IO ElapsedP
timeCurrentP :: IO ElapsedP
timeCurrentP = IO ElapsedP
systemGetElapsedP
dateCurrent :: IO DateTime
dateCurrent :: IO DateTime
dateCurrent = ElapsedP -> DateTime
forall t. Timeable t => t -> DateTime
timeGetDateTimeOfDay (ElapsedP -> DateTime) -> IO ElapsedP -> IO DateTime
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO ElapsedP
timeCurrentP
localDateCurrent :: IO (LocalTime DateTime)
localDateCurrent :: IO (LocalTime DateTime)
localDateCurrent = TimezoneOffset -> LocalTime DateTime -> LocalTime DateTime
forall t. Time t => TimezoneOffset -> LocalTime t -> LocalTime t
localTimeSetTimezone (TimezoneOffset -> LocalTime DateTime -> LocalTime DateTime)
-> IO TimezoneOffset
-> IO (LocalTime DateTime -> LocalTime DateTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO TimezoneOffset
timezoneCurrent
IO (LocalTime DateTime -> LocalTime DateTime)
-> IO (LocalTime DateTime) -> IO (LocalTime DateTime)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (DateTime -> LocalTime DateTime
forall t. Time t => t -> LocalTime t
localTimeFromGlobal (DateTime -> LocalTime DateTime)
-> IO DateTime -> IO (LocalTime DateTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO DateTime
dateCurrent)
localDateCurrentAt :: TimezoneOffset -> IO (LocalTime DateTime)
localDateCurrentAt :: TimezoneOffset -> IO (LocalTime DateTime)
localDateCurrentAt TimezoneOffset
tz = TimezoneOffset -> LocalTime DateTime -> LocalTime DateTime
forall t. Time t => TimezoneOffset -> LocalTime t -> LocalTime t
localTimeSetTimezone TimezoneOffset
tz (LocalTime DateTime -> LocalTime DateTime)
-> (DateTime -> LocalTime DateTime)
-> DateTime
-> LocalTime DateTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DateTime -> LocalTime DateTime
forall t. Time t => t -> LocalTime t
localTimeFromGlobal (DateTime -> LocalTime DateTime)
-> IO DateTime -> IO (LocalTime DateTime)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO DateTime
dateCurrent
timezoneCurrent :: IO TimezoneOffset
timezoneCurrent :: IO TimezoneOffset
timezoneCurrent = IO TimezoneOffset
systemGetTimezone