time-exts-1.0.2: Efficient Timestamps

Safe HaskellNone

Data.Time.Exts.Local

Contents

Description

Types and functions for local timestamps.

Synopsis

Local Class

Local Timestamps

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.