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
- 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
Enum Seconds Source # | |
Eq Seconds Source # | |
Integral Seconds Source # | |
Defined in Time.Types | |
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 :: (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 # | |
Num Seconds Source # | |
Ord Seconds Source # | |
Read Seconds Source # | |
Real Seconds Source # | |
Defined in Time.Types toRational :: Seconds -> Rational # | |
Show Seconds Source # | |
NFData Seconds Source # | |
Defined in Time.Types | |
TimeInterval Seconds Source # | |
Number of minutes without a referential.
Instances
Enum Minutes Source # | |
Eq Minutes Source # | |
Integral Minutes Source # | |
Defined in Time.Types | |
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 :: (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 # | |
Num Minutes Source # | |
Ord Minutes Source # | |
Read Minutes Source # | |
Real Minutes Source # | |
Defined in Time.Types toRational :: Minutes -> Rational # | |
Show Minutes Source # | |
NFData Minutes Source # | |
Defined in Time.Types | |
TimeInterval Minutes Source # | |
Number of hours without a referential.
Instances
Enum 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 # 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 :: (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 # | |
Num Hours Source # | |
Ord Hours Source # | |
Read Hours Source # | |
Real Hours Source # | |
Defined in Time.Types toRational :: Hours -> Rational # | |
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 # | |
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 # 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 :: (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 # | |
Ord Month Source # | |
Read Month Source # | |
Show Month Source # | |
Day of the week
the enumeration starts on Sunday.
Instances
Bounded WeekDay Source # | |
Enum 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 # 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 :: (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 # | |
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 # 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 :: (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 # | |
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 # 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 :: (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 # | |
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 # 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 :: (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 # | |
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 # 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 :: (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 # | |
Ord DateTime Source # | |
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 # |