Safe Haskell | None |
---|
Types and functions for local timestamps.
- class Local x
- data LocalDate = LocalDate {
- _loc_day_base :: !Int32
- _loc_day_zone :: !Int16
- data LocalDateTime = LocalDateTime {
- _loc_sec_base :: !Int64
- _loc_sec_zone :: !Int16
- data LocalDateTimeMillis = LocalDateTimeMillis {
- _loc_mil_base :: !Int64
- _loc_mil_mill :: !Int16
- _loc_mil_zone :: !Int16
- data LocalDateTimeMicros = LocalDateTimeMicros {
- _loc_mic_base :: !Int64
- _loc_mic_micr :: !Int32
- _loc_mic_zone :: !Int16
- data LocalDateTimeNanos = LocalDateTimeNanos {
- _loc_nan_base :: !Int64
- _loc_nan_nano :: !Int32
- _loc_nan_zone :: !Int16
- data LocalDateTimePicos = LocalDateTimePicos {
- _loc_pic_base :: !Int64
- _loc_pic_pico :: !Int64
- _loc_pic_zone :: !Int16
- createLocalDate :: Year -> Month -> Day -> TimeZone -> LocalDate
- createLocalDateTime :: Year -> Month -> Day -> Hour -> Minute -> Second -> TimeZone -> LocalDateTime
- createLocalDateTimeMillis :: Year -> Month -> Day -> Hour -> Minute -> Second -> Millis -> TimeZone -> LocalDateTimeMillis
- createLocalDateTimeMicros :: Year -> Month -> Day -> Hour -> Minute -> Second -> Micros -> TimeZone -> LocalDateTimeMicros
- createLocalDateTimeNanos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Nanos -> TimeZone -> LocalDateTimeNanos
- createLocalDateTimePicos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Picos -> TimeZone -> LocalDateTimePicos
- getCurrentLocalDate :: City -> IO LocalDate
- getCurrentLocalDateTime :: City -> IO LocalDateTime
- getCurrentLocalDateTimeMillis :: City -> IO LocalDateTimeMillis
- getCurrentLocalDateTimeMicros :: City -> IO LocalDateTimeMicros
- getCurrentLocalDateTimeNanos :: City -> IO LocalDateTimeNanos
- getCurrentLocalDateTimePicos :: City -> IO LocalDateTimePicos
- getCurrentLocalDate' :: TransitionTimes -> IO LocalDate
- getCurrentLocalDateTime' :: TransitionTimes -> IO LocalDateTime
- getCurrentLocalDateTimeMillis' :: TransitionTimes -> IO LocalDateTimeMillis
- getCurrentLocalDateTimeMicros' :: TransitionTimes -> IO LocalDateTimeMicros
- getCurrentLocalDateTimeNanos' :: TransitionTimes -> IO LocalDateTimeNanos
- getCurrentLocalDateTimePicos' :: TransitionTimes -> IO LocalDateTimePicos
- type TransitionTimes = [LocalDateTime]
- getTransitionTimes :: City -> IO TransitionTimes
- baseUnixToUTC :: Int64 -> Int64
- baseUTCToUnix :: Int64 -> (Int64, Second)
Local Class
A class of local timestamps.
Local Timestamps
A local date.
LocalDate | |
|
data LocalDateTime Source
A local date and time.
LocalDateTime | |
|
data LocalDateTimeMillis Source
A local date and time with millisecond granularity.
LocalDateTimeMillis | |
|
data LocalDateTimeMicros Source
A local date and time with microsecond granularity.
LocalDateTimeMicros | |
|
data LocalDateTimeNanos Source
A local date and time with nanosecond granularity.
LocalDateTimeNanos | |
|
data LocalDateTimePicos Source
A local date and time with picosecond granularity.
LocalDateTimePicos | |
|
Create Local Timestamps
createLocalDate :: Year -> Month -> Day -> TimeZone -> LocalDateSource
Create a local date.
>>> createLocalDate 2013 11 03 Pacific_Standard_Time 2013-11-03 PST
createLocalDateTime :: Year -> Month -> Day -> Hour -> Minute -> Second -> TimeZone -> LocalDateTimeSource
Create a local date and time.
>>> createLocalDateTime 2013 11 03 22 55 52 South_Africa_Standard_Time 2013-11-03 22:55:52 SAST
createLocalDateTimeMillis :: Year -> Month -> Day -> Hour -> Minute -> Second -> Millis -> TimeZone -> LocalDateTimeMillisSource
Create a local date and time with millisecond granularity.
>>> createLocalDateTimeMillis 2013 11 03 13 57 43 830 Mountain_Standard_Time 2013-11-03 13:57:43.830 MST
createLocalDateTimeMicros :: Year -> Month -> Day -> Hour -> Minute -> Second -> Micros -> TimeZone -> LocalDateTimeMicrosSource
Create a local date and time with microsecond granularity.
>>> createLocalDateTimeMicros 2013 11 03 21 01 42 903539 Coordinated_Universal_Time 2013-11-03 21:01:42.903539 UTC
createLocalDateTimeNanos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Nanos -> TimeZone -> LocalDateTimeNanosSource
Create a local date and time with nanosecond granularity.
>>> createLocalDateTimeNanos 2013 11 04 06 05 07 016715087 Japan_Standard_Time 2013-11-04 06:05:07.016715087 JST
createLocalDateTimePicos :: Year -> Month -> Day -> Hour -> Minute -> Second -> Picos -> TimeZone -> LocalDateTimePicosSource
Create a local date and time with picosecond granularity.
>>> createLocalDateTimePicos 2013 11 03 23 13 56 838238648311 Eastern_European_Time 2013-11-03 23:13:56.838238648311 EET
Get Current Local Timestamps
getCurrentLocalDate :: City -> IO LocalDateSource
Get the current local date from the system clock.
>>> getCurrentLocalDate London 2013-11-03 GMT
getCurrentLocalDateTime :: City -> IO LocalDateTimeSource
Get the current local date and time from the system clock.
>>> getCurrentLocalDateTime New_York 2013-11-03 16:38:16 EST
getCurrentLocalDateTimeMillis :: City -> IO LocalDateTimeMillisSource
Get the current local date and time with millisecond granularity from the system clock.
>>> getCurrentLocalDateTimeMillis Auckland 2013-11-04 10:46:13.123 NZDT
getCurrentLocalDateTimeMicros :: City -> IO LocalDateTimeMicrosSource
Get the current local date and time with microsecond granularity from the system clock.
>>> getCurrentLocalDateTimeMicros Tel_Aviv 2013-11-03 23:55:30.935387 IST
getCurrentLocalDateTimeNanos :: City -> IO LocalDateTimeNanosSource
Get the current local date and time with nanosecond granularity from the system clock.
>>> getCurrentLocalDateTimeNanos Brussels 2013-11-03 23:01:07.337488000 CET
Note that this functions calls gettimeofday()
behind the scenes. Therefore, the resultant
timestamp will have nanosecond granularity, but only microsecond resolution.
getCurrentLocalDateTimePicos :: City -> IO LocalDateTimePicosSource
Get the current local date and time with picosecond granularity from the system clock.
>>> getCurrentLocalDateTime Karachi 2013-11-04 03:18:30 PKT
Note that this functions calls gettimeofday()
behind the scenes. Therefore, the resultant
timestamp will have picosecond granularity, but only microsecond resolution.
getCurrentLocalDate' :: TransitionTimes -> IO LocalDateSource
Get the current local date from the system clock using preloaded transition times.
>>> ttimes <- getTransitionTimes Tokyo >>> getCurrentLocalDate' ttimes 2013-11-04 JST
Use this function if you need to get the current local date more than once. The use of preloaded transition times will avoid unnecessary parsing of Olson files.
getCurrentLocalDateTime' :: TransitionTimes -> IO LocalDateTimeSource
Get the current local date and time from the system clock using preloaded transition times.
>>> ttimes <- getTransitionTimes Moscow >>> getCurrentLocalDateTime' ttimes 2013-11-04 01:41:50 MSK
Use this function if you need to get the current local date and time more than once. The use of preloaded transition times will avoid unnecessary parsing of Olson files.
getCurrentLocalDateTimeMillis' :: TransitionTimes -> IO LocalDateTimeMillisSource
Get the current local date and time with millisecond granularity from the system clock using preloaded transition times.
>>> ttimes <- getTransitionTimes Tehran >>> getCurrentLocalDateTimeMillis' ttimes 2013-11-04 01:20:49.435 IRST
Use this function if you need to get the current local date and time with millisecond granularity more than once. The use of preloaded transition times will avoid unnecessary parsing of Olson files.
getCurrentLocalDateTimeMicros' :: TransitionTimes -> IO LocalDateTimeMicrosSource
Get the current local date and time with microsecond granularity from the system clock using preloaded transition times.
>>> ttimes <- getTransitionTimes Sao_Paulo >>> getCurrentLocalDateTimeMicros' ttimes 2013-11-03 19:58:50.405806 BRST
Use this function if you need to get the current local date and time with microsecond granularity more than once. The use of preloaded transition times will avoid unnecessary parsing of Olson files.
getCurrentLocalDateTimeNanos' :: TransitionTimes -> IO LocalDateTimeNanosSource
Get the current local date and time with nanosecond granularity from the system clock using preloaded transition times.
>>> ttimes <- getTransitionTimes Mogadishu >>> getCurrentLocalDateTimeNanos' ttimes 2013-11-04 01:15:08.664426000 EAT
Use this function if you need to get the current local date and time with nanosecond granularity more than once. The use of preloaded transition times will avoid unnecessary parsing of Olson files.
Note that this functions calls gettimeofday()
behind the scenes. Therefore, the resultant
timestamp will have nanosecond granularity, but only microsecond resolution.
getCurrentLocalDateTimePicos' :: TransitionTimes -> IO LocalDateTimePicosSource
Get the current local date and time with picosecond granularity from the system clock using preloaded transition times.
>>> ttimes <- getTransitionTimes Baghdad >>> getCurrentLocalDateTimePicos' ttimes 2013-11-04 01:20:57.502906000000 AST
Use this function if you need to get the current local date and time with picosecond granularity more than once. The use of preloaded transition times will avoid unnecessary parsing of Olson files.
Note that this functions calls gettimeofday()
behind the scenes. Therefore, the resultant
timestamp will have picosecond granularity, but only microsecond resolution.
Transition Times
type TransitionTimes = [LocalDateTime]Source
A list of transition times.
getTransitionTimes :: City -> IO TransitionTimesSource
Get a list of transition times for the given city.
Base Conversions
baseUnixToUTC :: Int64 -> Int64Source
Convert a Unix base into a UTC base.
baseUTCToUnix :: Int64 -> (Int64, Second)Source
Convert a UTC base into a Unix base and leap second.