License | BSD-style |
---|---|
Maintainer | Vincent Hanquez <vincent@snarc.org> |
Safe Haskell | Safe-Inferred |
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
Data Seconds Source # | |
Defined in Time.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Seconds -> c Seconds # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Seconds # toConstr :: Seconds -> Constr # dataTypeOf :: Seconds -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Seconds) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Seconds) # gmapT :: (forall b. Data b => b -> b) -> Seconds -> Seconds # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Seconds -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Seconds -> r # gmapQ :: (forall d. Data d => d -> u) -> Seconds -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Seconds -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Seconds -> m Seconds # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Seconds -> m Seconds # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Seconds -> m Seconds # | |
Enum Seconds Source # | |
Num Seconds Source # | |
Read Seconds Source # | |
Integral Seconds Source # | |
Defined in Time.Types | |
Real Seconds Source # | |
Defined in Time.Types toRational :: Seconds -> Rational # | |
Show Seconds Source # | |
NFData Seconds Source # | |
Defined in Time.Types | |
Eq Seconds Source # | |
Ord Seconds Source # | |
TimeInterval Seconds Source # | |
Number of minutes without a referential.
Instances
Data Minutes Source # | |
Defined in Time.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Minutes -> c Minutes # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Minutes # toConstr :: Minutes -> Constr # dataTypeOf :: Minutes -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Minutes) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Minutes) # gmapT :: (forall b. Data b => b -> b) -> Minutes -> Minutes # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Minutes -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Minutes -> r # gmapQ :: (forall d. Data d => d -> u) -> Minutes -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Minutes -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Minutes -> m Minutes # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Minutes -> m Minutes # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Minutes -> m Minutes # | |
Enum Minutes Source # | |
Num Minutes Source # | |
Read Minutes Source # | |
Integral Minutes Source # | |
Defined in Time.Types | |
Real Minutes Source # | |
Defined in Time.Types toRational :: Minutes -> Rational # | |
Show Minutes Source # | |
NFData Minutes Source # | |
Defined in Time.Types | |
Eq Minutes Source # | |
Ord Minutes Source # | |
TimeInterval Minutes Source # | |
Number of hours without a referential.
Instances
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Hours # dataTypeOf :: Hours -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Hours) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Hours) # gmapT :: (forall b. Data b => b -> b) -> Hours -> Hours # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Hours -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Hours -> r # gmapQ :: (forall d. Data d => d -> u) -> Hours -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Hours -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Hours -> m Hours # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Hours -> m Hours # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Hours -> m Hours # | |
Enum Hours Source # | |
Num Hours Source # | |
Read Hours Source # | |
Integral Hours Source # | |
Real Hours Source # | |
Defined in Time.Types toRational :: Hours -> Rational # | |
Show Hours Source # | |
NFData Hours Source # | |
Defined in Time.Types | |
Eq Hours Source # | |
Ord Hours Source # | |
TimeInterval Hours Source # | |
class TimeInterval i where Source #
Represent any time interval that has an equivalent value to a number of seconds.
Instances
TimeInterval Duration Source # | |
TimeInterval Hours Source # | |
TimeInterval Minutes Source # | |
TimeInterval NanoSeconds Source # | |
Defined in Time.Types toSeconds :: NanoSeconds -> Seconds Source # fromSeconds :: Seconds -> (NanoSeconds, Seconds) Source # | |
TimeInterval Seconds Source # | |
Time enumeration
Month of the year
Instances
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Month # dataTypeOf :: Month -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Month) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Month) # gmapT :: (forall b. Data b => b -> b) -> Month -> Month # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Month -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Month -> r # gmapQ :: (forall d. Data d => d -> u) -> Month -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Month -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Month -> m Month # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Month -> m Month # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Month -> m Month # | |
Bounded Month Source # | |
Enum Month Source # | |
Read Month Source # | |
Show Month Source # | |
Eq Month Source # | |
Ord Month Source # | |
Day of the week
the enumeration starts on Sunday.
Instances
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c WeekDay # toConstr :: WeekDay -> Constr # dataTypeOf :: WeekDay -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c WeekDay) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c WeekDay) # gmapT :: (forall b. Data b => b -> b) -> WeekDay -> WeekDay # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> WeekDay -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> WeekDay -> r # gmapQ :: (forall d. Data d => d -> u) -> WeekDay -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> WeekDay -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> WeekDay -> m WeekDay # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> WeekDay -> m WeekDay # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> WeekDay -> m WeekDay # | |
Bounded WeekDay Source # | |
Enum WeekDay Source # | |
Read WeekDay Source # | |
Show WeekDay Source # | |
Eq WeekDay Source # | |
Ord 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
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Elapsed # toConstr :: Elapsed -> Constr # dataTypeOf :: Elapsed -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Elapsed) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Elapsed) # gmapT :: (forall b. Data b => b -> b) -> Elapsed -> Elapsed # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Elapsed -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Elapsed -> r # gmapQ :: (forall d. Data d => d -> u) -> Elapsed -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Elapsed -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Elapsed -> m Elapsed # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Elapsed -> m Elapsed # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Elapsed -> m Elapsed # | |
Num Elapsed Source # | |
Read Elapsed Source # | |
Show Elapsed Source # | |
NFData Elapsed Source # | |
Defined in Time.Types | |
Eq Elapsed Source # | |
Ord Elapsed Source # | |
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
Data ElapsedP Source # | |
Defined in Time.Types gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ElapsedP -> c ElapsedP # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ElapsedP # toConstr :: ElapsedP -> Constr # dataTypeOf :: ElapsedP -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ElapsedP) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ElapsedP) # gmapT :: (forall b. Data b => b -> b) -> ElapsedP -> ElapsedP # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedP -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ElapsedP -> r # gmapQ :: (forall d. Data d => d -> u) -> ElapsedP -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> ElapsedP -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> ElapsedP -> m ElapsedP # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedP -> m ElapsedP # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ElapsedP -> m ElapsedP # | |
Num ElapsedP Source # | |
Read ElapsedP Source # | |
Real ElapsedP Source # | |
Defined in Time.Types toRational :: ElapsedP -> Rational # | |
Show ElapsedP Source # | |
NFData ElapsedP Source # | |
Defined in Time.Types | |
Eq ElapsedP Source # | |
Ord ElapsedP Source # | |
Time ElapsedP Source # | |
Defined in Data.Hourglass.Time timeFromElapsedP :: ElapsedP -> ElapsedP Source # timeFromElapsed :: Elapsed -> ElapsedP Source # | |
Timeable ElapsedP Source # | |
Defined in Data.Hourglass.Time timeGetElapsedP :: ElapsedP -> ElapsedP Source # timeGetElapsed :: ElapsedP -> Elapsed Source # |
Human friendly format
Calendar time
human date representation using common calendar
Instances
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Date # dataTypeOf :: Date -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Date) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Date) # gmapT :: (forall b. Data b => b -> b) -> Date -> Date # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Date -> r # gmapQ :: (forall d. Data d => d -> u) -> Date -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> Date -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Date -> m Date # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Date -> m Date # | |
Read Date Source # | |
Show Date Source # | |
NFData Date Source # | |
Defined in Time.Types | |
Eq Date Source # | |
Ord Date Source # | |
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
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c TimeOfDay # toConstr :: TimeOfDay -> Constr # dataTypeOf :: TimeOfDay -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c TimeOfDay) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c TimeOfDay) # gmapT :: (forall b. Data b => b -> b) -> TimeOfDay -> TimeOfDay # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> TimeOfDay -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> TimeOfDay -> r # gmapQ :: (forall d. Data d => d -> u) -> TimeOfDay -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> TimeOfDay -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> TimeOfDay -> m TimeOfDay # | |
Read TimeOfDay Source # | |
Show TimeOfDay Source # | |
NFData TimeOfDay Source # | |
Defined in Time.Types | |
Eq TimeOfDay Source # | |
Ord TimeOfDay Source # | |
Defined in Time.Types |
Date and Time
Instances
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 # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c DateTime # toConstr :: DateTime -> Constr # dataTypeOf :: DateTime -> DataType # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c DateTime) # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c DateTime) # gmapT :: (forall b. Data b => b -> b) -> DateTime -> DateTime # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> DateTime -> r # gmapQ :: (forall d. Data d => d -> u) -> DateTime -> [u] # gmapQi :: Int -> (forall d. Data d => d -> u) -> DateTime -> u # gmapM :: Monad m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> DateTime -> m DateTime # | |
Read DateTime Source # | |
Show DateTime Source # | |
NFData DateTime Source # | |
Defined in Time.Types | |
Eq DateTime Source # | |
Ord DateTime Source # | |
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 # |