timezone-series-0.1.8: Enhanced timezone handling for Data.Time

Data.Time.LocalTime.TimeZone.Series

Description

A TimeZoneSeries describes a timezone by specifying the various clock settings that occurred in the past and are scheduled to occur in the future for the timezone.

# Representing a timezone

A TimeZoneSeries describes a timezone with a set of TimeZone objects. Each TimeZone object describes the clock setting in the timezone for a specific period of history during which the clocks do not change.

Most operating systems provide information about timezone series for the local timezone and for many other timezones of the world. On MS Windows systems, this information can be read from the registry. On other systems, this information is typically provided in the form of Olson timezone files: /etc/localtime (or some other file) for the local timezone, and files located in /usr/share/zoneinfo/ or /etc/zoneinfo/ (or some other directory) for other timezones.

A TimeZoneSeries consists of a default TimeZone object and a sequence of pairs of a UTCTime and a TimeZone object. Each UTCTime indicates a moment at which the clocks changed, and the corresponding TimeZone object describes the new state of the clocks after the change. The default TimeZone object is used for times preceding the earliest UTCTime, or if the sequence of pairs is empty. The times in the sequence are in order from latest to earlist (note that this is the opposite of the way that they are stored in an Olson timezone file).

Constructors

 TimeZoneSeries FieldstzsTimeZone :: TimeZoneThe default timezone statetzsTransitions :: [(UTCTime, TimeZone)]A list of pairs of the time of a change of clocks and the new timezone state after the change

Instances

 Source # Methods Source # Methods Source # Methods Source # MethodsshowList :: [TimeZoneSeries] -> ShowS # Source # Methodsrnf :: TimeZoneSeries -> () # Source # Methods Source # MethodsbuildTime :: TimeLocale -> [(Char, String)] -> Maybe TimeZoneSeries #

Given a timezone represented by a TimeZoneSeries, and a UTCTime, provide the state of the timezone's clocks at that time.

When a clock change moves the clock forward, local times that are between the wall clock time before the change and the wall clock time after the change cannot occur.

When a clock change moves the clock backward, local times that are between the wall clock time before the change and the wall clock time after the change occur twice.

The latest non-summer TimeZone in a TimeZoneSeries is in some sense representative of the timezone.

## Converting between UTC and local time

The following functions are variants on functions in Data.Time.LocalTime that convert between UTC and local time. The originals can give a wrong result if the TimeZone used for the conversion is not actually in effect at the specified time. These variants use a TimeZoneSeries instead of a TimeZone.

When converting from an invalid local time, the local time is interpreted as if the time change that made it invalid never happened. When converting from a redundant local time, the latest possible interpretation is used. Use the functions isValidLocalTime and isRedundantLocalTime to detect these conditions.

Convert a UTC time to local time using the TimeZone that is in effect at that time in the timezone represented by TimeZoneSeries.

Convert a local time to UTC using the TimeZone that is in effect at that time in the timezone represented by TimeZoneSeries. Local times that are invalid or redundant are treated as described above.

# Representing a moment in a timezone

A ZoneSeriesTime represents a moment of time in the context of a particular timezone.

Constructors

 ZoneSeriesTime Fields

Instances

 Source # Methods Source # Methods Source # Methods Source # MethodsshowList :: [ZoneSeriesTime] -> ShowS # Source # Methods Source # MethodsbuildTime :: TimeLocale -> [(Char, String)] -> Maybe ZoneSeriesTime #

Use a trivial TimeZoneSeries containing only the TimeZone of the ZonedTime, and use it to define a ZoneSeriesTime.

The local time represented by a ZoneSeriesTime

The TimeZone that is in effect at the moment represented by a ZoneSeriesTime.

The ZoneSeriesTime that represents the given local time in the given timezone. Local times that are invalid or redundant are treated as described below.