time-exts-1.1.0: Efficient Timestamps

Safe HaskellNone

Data.Time.Exts.Local

Contents

Description

Local timestamps of varying granularity.

Synopsis

Local Class

class Local u whereSource

The local timestamp type class.

Methods

localBase :: u -> Int64Source

Get the base component of a local timestamp.

localZone :: u -> Word8Source

Get the zone component of a local timestamp.

Local Timestamps

Create Local Timestamps

createLocalDate :: Year -> Month -> Day -> TimeZone -> LocalDateSource

Create a local date.

 >>> createLocalDate 2013 November 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 November 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 November 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 November 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 November 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 November 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.

 >>> getCurrentLocalDateTimePicos Karachi
 2013-11-04 22:05:17.556043000000 PKT

Note that this functions calls gettimeofday() behind the scenes. Therefore, the resultant timestamp will have picosecond granularity, but only microsecond resolution.

Time Zone Transition Times

getTransitions :: City -> IO [Transition]Source

Get a list of time zone transition times for the given city.

Get Current Local Timestamps Using Preloaded Time Zone Transitions Times

getCurrentLocalDate' :: [Transition] -> IO LocalDateSource

Get the current local date from the system clock using preloaded transition times.

 >>> ttimes <- getTransitions 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' :: [Transition] -> IO LocalDateTimeSource

Get the current local date and time from the system clock using preloaded transition times.

 >>> ttimes <- getTransitions 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' :: [Transition] -> IO LocalDateTimeMillisSource

Get the current local date and time with millisecond granularity from the system clock using preloaded transition times.

 >>> ttimes <- getTransitions 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' :: [Transition] -> IO LocalDateTimeMicrosSource

Get the current local date and time with microsecond granularity from the system clock using preloaded transition times.

 >>> ttimes <- getTransitions 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' :: [Transition] -> IO LocalDateTimeNanosSource

Get the current local date and time with nanosecond granularity from the system clock using preloaded transition times.

 >>> ttimes <- getTransitions 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' :: [Transition] -> IO LocalDateTimePicosSource

Get the current local date and time with picosecond granularity from the system clock using preloaded transition times.

 >>> ttimes <- getTransitions 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.

Pretty Local Timestamps

prettyLocalDate :: LocalDate -> StringSource

Show a local date as a pretty string.

 >>> prettyLocalDate $ createLocalDate 2014 September 25 Japan_Standard_Time 
 "Thursday, September 25th, 2014 (JST)"

prettyLocalDateTime :: DateTimeZone dtz => dtz -> StringSource

Show a local date and time as a pretty string.

 >>> getCurrentLocalDateTime Los_Angeles >>= return . prettyLocalDateTime 
 "2:17 AM, Wednesday, January 1st, 2014 (PST)"