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

Safe HaskellSafe
LanguageHaskell2010

Data.Time.LocalTime.TimeZone.Series

Contents

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.

Synopsis

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.

data TimeZoneSeries Source #

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 

Fields

timeZoneFromSeries :: TimeZoneSeries -> UTCTime -> TimeZone Source #

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

isValidLocalTime :: TimeZoneSeries -> LocalTime -> Bool Source #

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.

isRedundantLocalTime :: TimeZoneSeries -> LocalTime -> Bool Source #

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.

latestNonSummer :: TimeZoneSeries -> TimeZone Source #

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.

utcToLocalTime' :: TimeZoneSeries -> UTCTime -> LocalTime Source #

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

localTimeToUTC' :: TimeZoneSeries -> LocalTime -> UTCTime Source #

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

zonedTimeToZoneSeriesTime :: ZonedTime -> ZoneSeriesTime Source #

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

zoneSeriesTimeToLocalTime :: ZoneSeriesTime -> LocalTime Source #

The local time represented by a ZoneSeriesTime

zoneSeriesTimeZone :: ZoneSeriesTime -> TimeZone Source #

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

localTimeToZoneSeriesTime :: TimeZoneSeries -> LocalTime -> ZoneSeriesTime Source #

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