Data.Time.LocalTime.TimeZone.Series

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

Safe Haskell | Safe-Inferred
Language | Haskell2010

Data.Time.LocalTime.TimeZone.Series

Contents

- Representing a timezone
  - Converting between UTC and local time
- Representing a moment in a timezone

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

- data TimeZoneSeries = TimeZoneSeries {
  - tzsTimeZone :: TimeZone
  - tzsTransitions :: [(UTCTime, TimeZone)]
  }
- timeZoneFromSeries :: TimeZoneSeries -> UTCTime -> TimeZone
- isValidLocalTime :: TimeZoneSeries -> LocalTime -> Bool
- isRedundantLocalTime :: TimeZoneSeries -> LocalTime -> Bool
- latestNonSummer :: TimeZoneSeries -> TimeZone
- utcToLocalTime' :: TimeZoneSeries -> UTCTime -> LocalTime
- localTimeToUTC' :: TimeZoneSeries -> LocalTime -> UTCTime
- data ZoneSeriesTime = ZoneSeriesTime {
  - zoneSeriesTimeToUTC :: UTCTime
  - zoneSeriesTimeSeries :: TimeZoneSeries
  }
- zonedTimeToZoneSeriesTime :: ZonedTime -> ZoneSeriesTime
- zoneSeriesTimeToLocalTime :: ZoneSeriesTime -> LocalTime
- zoneSeriesTimeZone :: ZoneSeriesTime -> TimeZone
- localTimeToZoneSeriesTime :: TimeZoneSeries -> LocalTime -> ZoneSeriesTime

# 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 #

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 tzsTimeZone :: TimeZone The default timezone state tzsTransitions :: [(UTCTime, TimeZone)] A list of pairs of the time of a change of clocks and the new timezone state after the change

#### Instances

Instances details

Eq TimeZoneSeries # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods (==) :: TimeZoneSeries -> TimeZoneSeries -> Bool (/=) :: TimeZoneSeries -> TimeZoneSeries -> Bool
Ord TimeZoneSeries # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods compare :: TimeZoneSeries -> TimeZoneSeries -> Ordering (<) :: TimeZoneSeries -> TimeZoneSeries -> Bool (<=) :: TimeZoneSeries -> TimeZoneSeries -> Bool (>) :: TimeZoneSeries -> TimeZoneSeries -> Bool (>=) :: TimeZoneSeries -> TimeZoneSeries -> Bool max :: TimeZoneSeries -> TimeZoneSeries -> TimeZoneSeries min :: TimeZoneSeries -> TimeZoneSeries -> TimeZoneSeries
Read TimeZoneSeries # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods readsPrec :: Int -> ReadS TimeZoneSeries readList :: ReadS [TimeZoneSeries] readPrec :: ReadPrec TimeZoneSeries readListPrec :: ReadPrec [TimeZoneSeries]
Show TimeZoneSeries # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods showsPrec :: Int -> TimeZoneSeries -> ShowS show :: TimeZoneSeries -> String showList :: [TimeZoneSeries] -> ShowS
FormatTime TimeZoneSeries # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> TimeZoneSeries -> String)
ParseTime TimeZoneSeries # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods substituteTimeSpecifier :: proxy TimeZoneSeries -> TimeLocale -> Char -> Maybe String parseTimeSpecifier :: proxy TimeZoneSeries -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String buildTime :: TimeLocale -> [(Char, String)] -> Maybe TimeZoneSeries
NFData TimeZoneSeries # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods rnf :: TimeZoneSeries -> ()

timeZoneFromSeries :: TimeZoneSeries -> UTCTime -> TimeZone #

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 #

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 #

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 #

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 #

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 #

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

data ZoneSeriesTime #

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

Constructors

ZoneSeriesTime |
Fields zoneSeriesTimeToUTC :: UTCTime zoneSeriesTimeSeries :: TimeZoneSeries

#### Instances

Instances details

Eq ZoneSeriesTime # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods (==) :: ZoneSeriesTime -> ZoneSeriesTime -> Bool (/=) :: ZoneSeriesTime -> ZoneSeriesTime -> Bool
Ord ZoneSeriesTime # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods compare :: ZoneSeriesTime -> ZoneSeriesTime -> Ordering (<) :: ZoneSeriesTime -> ZoneSeriesTime -> Bool (<=) :: ZoneSeriesTime -> ZoneSeriesTime -> Bool (>) :: ZoneSeriesTime -> ZoneSeriesTime -> Bool (>=) :: ZoneSeriesTime -> ZoneSeriesTime -> Bool max :: ZoneSeriesTime -> ZoneSeriesTime -> ZoneSeriesTime min :: ZoneSeriesTime -> ZoneSeriesTime -> ZoneSeriesTime
Read ZoneSeriesTime # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods readsPrec :: Int -> ReadS ZoneSeriesTime readList :: ReadS [ZoneSeriesTime] readPrec :: ReadPrec ZoneSeriesTime readListPrec :: ReadPrec [ZoneSeriesTime]
Show ZoneSeriesTime # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods showsPrec :: Int -> ZoneSeriesTime -> ShowS show :: ZoneSeriesTime -> String showList :: [ZoneSeriesTime] -> ShowS
FormatTime ZoneSeriesTime # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods formatCharacter :: Bool -> Char -> Maybe (FormatOptions -> ZoneSeriesTime -> String)
ParseTime ZoneSeriesTime # |
Instance details Defined in Data.Time.LocalTime.TimeZone.Series Methods substituteTimeSpecifier :: proxy ZoneSeriesTime -> TimeLocale -> Char -> Maybe String parseTimeSpecifier :: proxy ZoneSeriesTime -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP String buildTime :: TimeLocale -> [(Char, String)] -> Maybe ZoneSeriesTime

zonedTimeToZoneSeriesTime :: ZonedTime -> ZoneSeriesTime #

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

zoneSeriesTimeToLocalTime :: ZoneSeriesTime -> LocalTime #

The local time represented by a `ZoneSeriesTime`

zoneSeriesTimeZone :: ZoneSeriesTime -> TimeZone #

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

localTimeToZoneSeriesTime :: TimeZoneSeries -> LocalTime -> 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.