Safe Haskell | None |
---|
Types and functions for Unix timestamps.
- class Unix x
- newtype UnixDate = UnixDate Int32
- newtype UnixDateTime = UnixDateTime Int64
- data UnixDateTimeMillis = UnixDateTimeMillis {
- _uni_mil_base :: !Int64
- _uni_mil_mill :: !Int16
- data UnixDateTimeMicros = UnixDateTimeMicros {
- _uni_mic_base :: !Int64
- _uni_mic_micr :: !Int32
- data UnixDateTimeNanos = UnixDateTimeNanos {
- _uni_nan_base :: !Int64
- _uni_nan_nano :: !Int32
- data UnixDateTimePicos = UnixDateTimePicos {
- _uni_pic_base :: !Int64
- _uni_pic_pico :: !Int64
- createUnixDate :: Year -> Month -> Day -> UnixDate
- createUnixDateTime :: Year -> Month -> Day -> Hour -> Minute -> Second -> UnixDateTime
- createUnixDateTimeMillis :: Year -> Month -> Day -> Hour -> Minute -> Second -> Millis -> UnixDateTimeMillis
- createUnixDateTimeMicros :: Year -> Month -> Day -> Hour -> Minute -> Second -> Micros -> UnixDateTimeMicros
- createUnixDateTimeNanos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Nanos -> UnixDateTimeNanos
- createUnixDateTimePicos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Picos -> UnixDateTimePicos
- getCurrentUnixDate :: IO UnixDate
- getCurrentUnixDateTime :: IO UnixDateTime
- getCurrentUnixDateTimeMillis :: IO UnixDateTimeMillis
- getCurrentUnixDateTimeMicros :: IO UnixDateTimeMicros
- getCurrentUnixDateTimeNanos :: IO UnixDateTimeNanos
- getCurrentUnixDateTimePicos :: IO UnixDateTimePicos
Unix Class
A class of Unix timestamps.
Unix Timestamps
A Unix date.
newtype UnixDateTime Source
A Unix date and time.
data UnixDateTimeMillis Source
A Unix date and time with millisecond granularity.
UnixDateTimeMillis | |
|
data UnixDateTimeMicros Source
A Unix date and time with microsecond granularity.
UnixDateTimeMicros | |
|
data UnixDateTimeNanos Source
A Unix date and time with nanosecond granularity.
UnixDateTimeNanos | |
|
data UnixDateTimePicos Source
A Unix date and time with picosecond granularity.
UnixDateTimePicos | |
|
Create Unix Timestamps
createUnixDate :: Year -> Month -> Day -> UnixDateSource
Create a Unix date.
>>> createUnixDate 2013 11 03 2013-11-03
createUnixDateTime :: Year -> Month -> Day -> Hour -> Minute -> Second -> UnixDateTimeSource
Create a Unix date and time.
>>> createUnixDateTime 2013 11 03 22 58 29 2013-11-03 22:58:29
createUnixDateTimeMillis :: Year -> Month -> Day -> Hour -> Minute -> Second -> Millis -> UnixDateTimeMillisSource
Create a Unix date and time with millisecond granularity.
>>> createUnixDateTimeMillis 2013 11 03 22 59 13 922 2013-11-03 22:59:13.922
createUnixDateTimeMicros :: Year -> Month -> Day -> Hour -> Minute -> Second -> Micros -> UnixDateTimeMicrosSource
Create a Unix date and time with microsecond granularity.
>>> createUnixDateTimeMicros 2013 11 03 23 00 13 573166 2013-11-03 23:00:13.573166
createUnixDateTimeNanos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Nanos -> UnixDateTimeNanosSource
Create a Unix date and time with nanosecond granularity.
>>> createUnixDateTimeNanos 2013 11 03 23 01 43 946387023 2013-11-03 23:01:43.946387023
createUnixDateTimePicos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Picos -> UnixDateTimePicosSource
Create a Unix date and time with picosecond granularity.
>>> createUnixDateTimePicos 2013 11 03 23 04 35 816235224967 2013-11-03 23:04:35.816235224967
Get Current Unix Timestamps
getCurrentUnixDate :: IO UnixDateSource
Get the current Unix date from the system clock.
>>> getCurrentUnixDate 2013-11-03
getCurrentUnixDateTime :: IO UnixDateTimeSource
Get the current Unix date and time from the system clock.
>>> getCurrentUnixDateTime 2013-11-03 23:09:38
getCurrentUnixDateTimeMillis :: IO UnixDateTimeMillisSource
Get the current Unix date and time with millisecond granularity from the system clock.
>>> getCurrentUnixDateTimeMillis 2013-11-03 23:09:51.986
getCurrentUnixDateTimeMicros :: IO UnixDateTimeMicrosSource
Get the current Unix date and time with microsecond granularity from the system clock.
>>> getCurrentUnixDateTimeMicros 2013-11-03 23:10:06.498559
getCurrentUnixDateTimeNanos :: IO UnixDateTimeNanosSource
Get the current Unix date and time with nanosecond granularity from the system clock.
>>> getCurrentUnixDateTimeNanos 2013-11-03 23:10:23.697893000
Note that this functions calls gettimeofday()
behind the scenes. Therefore, the resultant
timestamp will have nanosecond granularity, but only microsecond resolution.
getCurrentUnixDateTimePicos :: IO UnixDateTimePicosSource
Get the current Unix date and time with picosecond granularity from the system clock.
>>> getCurrentUnixDateTimePicos 2013-11-03 23:10:44.633032000000
Note that this functions calls gettimeofday()
behind the scenes. Therefore, the resultant
timestamp will have picosecond granularity, but only microsecond resolution.