License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Safe Haskell | None |
Language | Haskell2010 |
Basic times units and types.
While pratically some units could hold infinite values, for practical and efficient purpose they are limited to int64 types for seconds and int types for years.
Most units use the unix epoch referential, but by no means reduce portability. the unix referential works under the Windows platform or any other platforms.
Synopsis
- newtype NanoSeconds = NanoSeconds Int64
- newtype Seconds = Seconds Int64
- newtype Minutes = Minutes Int64
- newtype Hours = Hours Int64
-
class
TimeInterval
i
where
- toSeconds :: i -> Seconds
- fromSeconds :: Seconds -> (i, Seconds )
- data Month
- data WeekDay
- newtype TimezoneOffset = TimezoneOffset { }
- timezoneOffsetToSeconds :: TimezoneOffset -> Seconds
- timezone_UTC :: TimezoneOffset
- newtype Elapsed = Elapsed Seconds
- data ElapsedP = ElapsedP ! Elapsed ! NanoSeconds
- data Date = Date { }
- data TimeOfDay = TimeOfDay { }
- data DateTime = DateTime { }
Time units
newtype NanoSeconds Source #
Nanoseconds
Instances
Number of seconds without a referential.
Can hold a number between [-2^63,2^63-1], which should be good for some billions of years.
However, because of limitation in the calendar conversion currently used, seconds should be in the range [-2^55,2^55-1], which is good for only 1 billion of year.
Instances
Number of minutes without a referential.
Instances
Number of hours without a referential.
Instances
Enum Hours Source # | |
Defined in Time.Types succ :: Hours -> Hours Source # pred :: Hours -> Hours Source # toEnum :: Int -> Hours Source # fromEnum :: Hours -> Int Source # enumFrom :: Hours -> [ Hours ] Source # enumFromThen :: Hours -> Hours -> [ Hours ] Source # enumFromTo :: Hours -> Hours -> [ Hours ] Source # enumFromThenTo :: Hours -> Hours -> Hours -> [ Hours ] Source # |
|
Eq Hours Source # | |
Integral Hours Source # | |
Data Hours Source # | |
Defined in Time.Types gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Hours -> c Hours Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Hours Source # toConstr :: Hours -> Constr Source # dataTypeOf :: Hours -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Hours ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Hours ) Source # gmapT :: ( forall b. Data b => b -> b) -> Hours -> Hours Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Hours -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Hours -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> Hours -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> Hours -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Hours -> m Hours Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Hours -> m Hours Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Hours -> m Hours Source # |
|
Num Hours Source # | |
Ord Hours Source # | |
Defined in Time.Types |
|
Read Hours Source # | |
Real Hours Source # | |
Defined in Time.Types toRational :: Hours -> Rational Source # |
|
Show Hours Source # | |
NFData Hours Source # | |
Defined in Time.Types |
|
TimeInterval Hours Source # | |
class TimeInterval i where Source #
Represent any time interval that has an equivalent value to a number of seconds.
Instances
TimeInterval Hours Source # | |
TimeInterval Minutes Source # | |
TimeInterval Seconds Source # | |
TimeInterval NanoSeconds Source # | |
Defined in Time.Types toSeconds :: NanoSeconds -> Seconds Source # fromSeconds :: Seconds -> ( NanoSeconds , Seconds ) Source # |
|
TimeInterval Duration Source # | |
Time enumeration
Month of the year
Instances
Bounded Month Source # | |
Enum Month Source # | |
Defined in Time.Types succ :: Month -> Month Source # pred :: Month -> Month Source # toEnum :: Int -> Month Source # fromEnum :: Month -> Int Source # enumFrom :: Month -> [ Month ] Source # enumFromThen :: Month -> Month -> [ Month ] Source # enumFromTo :: Month -> Month -> [ Month ] Source # enumFromThenTo :: Month -> Month -> Month -> [ Month ] Source # |
|
Eq Month Source # | |
Data Month Source # | |
Defined in Time.Types gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Month -> c Month Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Month Source # toConstr :: Month -> Constr Source # dataTypeOf :: Month -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Month ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Month ) Source # gmapT :: ( forall b. Data b => b -> b) -> Month -> Month Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Month -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Month -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> Month -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> Month -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Month -> m Month Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Month -> m Month Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Month -> m Month Source # |
|
Ord Month Source # | |
Defined in Time.Types |
|
Read Month Source # | |
Show Month Source # | |
Day of the week
the enumeration starts on Sunday.
Instances
Bounded WeekDay Source # | |
Enum WeekDay Source # | |
Defined in Time.Types succ :: WeekDay -> WeekDay Source # pred :: WeekDay -> WeekDay Source # toEnum :: Int -> WeekDay Source # fromEnum :: WeekDay -> Int Source # enumFrom :: WeekDay -> [ WeekDay ] Source # enumFromThen :: WeekDay -> WeekDay -> [ WeekDay ] Source # enumFromTo :: WeekDay -> WeekDay -> [ WeekDay ] Source # enumFromThenTo :: WeekDay -> WeekDay -> WeekDay -> [ WeekDay ] Source # |
|
Eq WeekDay Source # | |
Data WeekDay Source # | |
Defined in Time.Types gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> WeekDay -> c WeekDay Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c WeekDay Source # toConstr :: WeekDay -> Constr Source # dataTypeOf :: WeekDay -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c WeekDay ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c WeekDay ) Source # gmapT :: ( forall b. Data b => b -> b) -> WeekDay -> WeekDay Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> WeekDay -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> WeekDay -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> WeekDay -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> WeekDay -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> WeekDay -> m WeekDay Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> WeekDay -> m WeekDay Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> WeekDay -> m WeekDay Source # |
|
Ord WeekDay Source # | |
Read WeekDay Source # | |
Show WeekDay Source # | |
Timezone
newtype TimezoneOffset Source #
Offset against UTC in minutes to obtain from UTC time, local time.
- a positive number represent a location East of UTC.
- a negative number represent a location West of UTC.
LocalTime t (-300) = t represent a time at UTC-5 LocalTime t (+480) = t represent a time at UTC+8
should be between -11H and +14H
Example: in AUSEDT (UTC+1000 with daylight = UTC+1100), local time is 15:47; Thus, UTC time is 04:47, and TimezoneOffset is +660 (minutes)
TimezoneOffset | |
|
Instances
timezoneOffsetToSeconds :: TimezoneOffset -> Seconds Source #
Return the number of seconds associated with a timezone
timezone_UTC :: TimezoneOffset Source #
The UTC timezone. offset of 0
Computer friendly format
Unix elapsed
A number of seconds elapsed since the unix epoch.
Instances
Eq Elapsed Source # | |
Data Elapsed Source # | |
Defined in Time.Types gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Elapsed -> c Elapsed Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Elapsed Source # toConstr :: Elapsed -> Constr Source # dataTypeOf :: Elapsed -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Elapsed ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Elapsed ) Source # gmapT :: ( forall b. Data b => b -> b) -> Elapsed -> Elapsed Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Elapsed -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Elapsed -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> Elapsed -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> Elapsed -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Elapsed -> m Elapsed Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Elapsed -> m Elapsed Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Elapsed -> m Elapsed Source # |
|
Num Elapsed Source # | |
Defined in Time.Types |
|
Ord Elapsed Source # | |
Read Elapsed Source # | |
Show Elapsed Source # | |
NFData Elapsed Source # | |
Defined in Time.Types |
|
Time Elapsed Source # | |
Defined in Data.Hourglass.Time timeFromElapsedP :: ElapsedP -> Elapsed Source # timeFromElapsed :: Elapsed -> Elapsed Source # |
|
Timeable Elapsed Source # | |
Defined in Data.Hourglass.Time timeGetElapsedP :: Elapsed -> ElapsedP Source # timeGetElapsed :: Elapsed -> Elapsed Source # |
A number of seconds and nanoseconds elapsed since the unix epoch.
Instances
Human friendly format
Calendar time
human date representation using common calendar
Instances
Eq Date Source # | |
Data Date Source # | |
Defined in Time.Types gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> Date -> c Date Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c Date Source # toConstr :: Date -> Constr Source # dataTypeOf :: Date -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c Date ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c Date ) Source # gmapT :: ( forall b. Data b => b -> b) -> Date -> Date Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> Date -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> Date -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> Date -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> Date -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> Date -> m Date Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> Date -> m Date Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> Date -> m Date Source # |
|
Ord Date Source # | |
Read Date Source # | |
Show Date Source # | |
NFData Date Source # | |
Defined in Time.Types |
|
Time Date Source # | |
Defined in Data.Hourglass.Time timeFromElapsedP :: ElapsedP -> Date Source # timeFromElapsed :: Elapsed -> Date Source # |
|
Timeable Date Source # | |
Defined in Data.Hourglass.Time timeGetElapsedP :: Date -> ElapsedP Source # timeGetElapsed :: Date -> Elapsed Source # timeGetNanoSeconds :: Date -> NanoSeconds Source # |
human time representation of hour, minutes, seconds in a day.
Instances
Eq TimeOfDay Source # | |
Data TimeOfDay Source # | |
Defined in Time.Types gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> TimeOfDay -> c TimeOfDay Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c TimeOfDay Source # toConstr :: TimeOfDay -> Constr Source # dataTypeOf :: TimeOfDay -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c TimeOfDay ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c TimeOfDay ) Source # gmapT :: ( forall b. Data b => b -> b) -> TimeOfDay -> TimeOfDay Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> TimeOfDay -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> TimeOfDay -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> TimeOfDay -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> TimeOfDay -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay Source # |
|
Ord TimeOfDay Source # | |
Defined in Time.Types |
|
Read TimeOfDay Source # | |
Show TimeOfDay Source # | |
NFData TimeOfDay Source # | |
Defined in Time.Types |
Date and Time
Instances
Eq DateTime Source # | |
Data DateTime Source # | |
Defined in Time.Types gfoldl :: ( forall d b. Data d => c (d -> b) -> d -> c b) -> ( forall g. g -> c g) -> DateTime -> c DateTime Source # gunfold :: ( forall b r. Data b => c (b -> r) -> c r) -> ( forall r. r -> c r) -> Constr -> c DateTime Source # toConstr :: DateTime -> Constr Source # dataTypeOf :: DateTime -> DataType Source # dataCast1 :: Typeable t => ( forall d. Data d => c (t d)) -> Maybe (c DateTime ) Source # dataCast2 :: Typeable t => ( forall d e. ( Data d, Data e) => c (t d e)) -> Maybe (c DateTime ) Source # gmapT :: ( forall b. Data b => b -> b) -> DateTime -> DateTime Source # gmapQl :: (r -> r' -> r) -> r -> ( forall d. Data d => d -> r') -> DateTime -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> ( forall d. Data d => d -> r') -> DateTime -> r Source # gmapQ :: ( forall d. Data d => d -> u) -> DateTime -> [u] Source # gmapQi :: Int -> ( forall d. Data d => d -> u) -> DateTime -> u Source # gmapM :: Monad m => ( forall d. Data d => d -> m d) -> DateTime -> m DateTime Source # gmapMp :: MonadPlus m => ( forall d. Data d => d -> m d) -> DateTime -> m DateTime Source # gmapMo :: MonadPlus m => ( forall d. Data d => d -> m d) -> DateTime -> m DateTime Source # |
|
Ord DateTime Source # | |
Defined in Time.Types |
|
Read DateTime Source # | |
Show DateTime Source # | |
NFData DateTime Source # | |
Defined in Time.Types |
|
Time DateTime Source # | |
Defined in Data.Hourglass.Time timeFromElapsedP :: ElapsedP -> DateTime Source # timeFromElapsed :: Elapsed -> DateTime Source # |
|
Timeable DateTime Source # | |
Defined in Data.Hourglass.Time timeGetElapsedP :: DateTime -> ElapsedP Source # timeGetElapsed :: DateTime -> Elapsed Source # |