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.
- 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
Nanoseconds
newtype Seconds
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.
newtype Minutes
Number of minutes without a referential.
newtype Hours
Number of hours without a referential.
class TimeInterval i where
Represent any time interval that has an equivalent value to a number of seconds.
fromSeconds :: Seconds -> (i, Seconds)
Time enumeration
data Month
Month of the year
data WeekDay
Day of the week
the enumeration starts on Sunday.
Timezone
newtype TimezoneOffset
Offset against UTC in minutes
- 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
TimezoneOffset | |
|
timezoneOffsetToSeconds :: TimezoneOffset -> Seconds
Return the number of seconds associated with a timezone
timezone_UTC :: TimezoneOffset
The UTC timezone. offset of 0
Computer friendly format
Unix elapsed
newtype Elapsed
A number of seconds elapsed since the unix epoch.
data ElapsedP
A number of seconds and nanoseconds elapsed since the unix epoch.