hodatime
Copyright(C) 2017 Jason Johnson
LicenseBSD-style (see the file LICENSE)
MaintainerJason Johnson <jason.johnson.081@gmail.com>
Stabilityexperimental
PortabilityPOSIX, Windows
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.HodaTime.ZonedDateTime

Description

This is the module for ZonedDateTime. A ZonedDateTime is a universal time, it represents the same moment anywhere in the world and is completely unambiguous. Each instance of a ZonedDateTime corresponds to exactly one point on a continuous time line.

Synopsis

Types

data ZonedDateTime cal Source #

A CalendarDateTime in a specific time zone. A ZonedDateTime is global and maps directly to a single Instant.

Instances

Instances details
IsCalendarDateTime cal => Show (ZonedDateTime cal) Source #

Renders a ZonedDateTime as the fromInstant call that reconstructs it from its physical Instant and zone.

Instance details

Defined in Data.HodaTime.ZonedDateTime.Internal

Eq (Date cal) => Eq (ZonedDateTime cal) Source # 
Instance details

Defined in Data.HodaTime.ZonedDateTime.Internal

Methods

(==) :: ZonedDateTime cal -> ZonedDateTime cal -> Bool #

(/=) :: ZonedDateTime cal -> ZonedDateTime cal -> Bool #

(IsCalendarDateTime cal, Eq (Date cal)) => Ord (ZonedDateTime cal) Source #

Orders ZonedDateTimes by the Instant they represent (their global/UTC position on the time line), falling back to the zone identifier as a tie-break so that two zones observing the same instant still have a total order. NOTE: this compares by physical time, not by the local wall-clock CalendarDateTime.

Instance details

Defined in Data.HodaTime.ZonedDateTime.Internal

Hashable (Date cal) => Hashable (ZonedDateTime cal) Source #

Hashes a ZonedDateTime by its identity: the local CalendarDateTime, the zone (by identifier) and the active transition. Consistent with (==), which compares those same components. NOTE: no NFData instance is provided because ZonedDateTime embeds a TimeZone, whose fingertree-based transition maps cannot be forced (see Internal).

Instance details

Defined in Data.HodaTime.ZonedDateTime.Internal

Methods

hashWithSalt :: Int -> ZonedDateTime cal -> Int #

hash :: ZonedDateTime cal -> Int #

Constructors

fromCalendarDateTimeLeniently :: (IsCalendar cal, IsCalendarDateTime cal) => CalendarDateTime cal -> TimeZone -> ZonedDateTime cal Source #

Returns the mapping of this CalendarDateTime within the given TimeZone, with "lenient" rules applied such that ambiguous values map to the earlier of the alternatives, and "skipped" values are shifted forward by the duration of the "gap".

fromCalendarDateTimeStrictly :: (MonadThrow m, IsCalendarDateTime cal) => CalendarDateTime cal -> TimeZone -> m (ZonedDateTime cal) Source #

Returns the mapping of this CalendarDateTime within the given TimeZone, with "strict" rules applied such that ambiguous or skipped date times return the requested failure response (e.g. Nothing, Left, exception, etc.)

fromInstant :: IsCalendarDateTime cal => Instant -> TimeZone -> ZonedDateTime cal Source #

Returns the ZonedDateTime represented by the passed Instant within the given TimeZone. This is always an unambiguous conversion.

Math

Conversion

toCalendarDate :: ZonedDateTime cal -> CalendarDate cal Source #

Return the CalendarDate represented by this ZonedDateTime.

toInstant :: IsCalendarDateTime cal => ZonedDateTime cal -> Instant Source #

Return the Instant (a universal, UTC-based moment) represented by this ZonedDateTime. This is the inverse of fromInstant: it takes the local CalendarDateTime back to its unadjusted instant and then removes the zone's UTC offset.

toLocalTime :: ZonedDateTime cal -> LocalTime Source #

Return the LocalTime represented by this ZonedDateTime.

withCalendar :: (IsCalendarDateTime a, IsCalendarDateTime b) => ZonedDateTime a -> ZonedDateTime b Source #

Re-express a ZonedDateTime in a different calendar, preserving the exact Instant and time zone; only the calendar that the local date/time is labelled in changes. The target calendar is chosen by the result type.

Accessors

inDst :: ZonedDateTime cal -> Bool Source #

Return a Bool specifying if this ZonedDateTime is currently in Daylight savings time.

zoneAbbreviation :: ZonedDateTime cal -> String Source #

Return a String representing the abbreviation for the TimeZone this ZonedDateTime is currently in.

zoneId :: ZonedDateTime cal -> String Source #

Return the identifier of this ZonedDateTimes time zone, e.g. Europe/Zurich (or UTC). Unlike zoneAbbreviation this is unambiguous, so it is the form to use when a value needs to round-trip through text.

year :: IsCalendar cal => ZonedDateTime cal -> Year Source #

Accessor for the Year of a ZonedDateTime.

month :: IsCalendar cal => ZonedDateTime cal -> Month cal Source #

Accessor for the Month of a ZonedDateTime.

day :: IsCalendar cal => ZonedDateTime cal -> DayOfMonth Source #

Accessor for the Day of a ZonedDateTime.

hour :: IsCalendar cal => ZonedDateTime cal -> Hour Source #

Accessor for the Hour of a ZonedDateTime.

minute :: IsCalendar cal => ZonedDateTime cal -> Minute Source #

Accessor for the Minute of a ZonedDateTime.

second :: IsCalendar cal => ZonedDateTime cal -> Second Source #

Accessor for the Second of a ZonedDateTime.

nanosecond :: IsCalendar cal => ZonedDateTime cal -> Nanosecond Source #

Accessor for the Nanosecond of a ZonedDateTime.

Special constructors

fromCalendarDateTimeAll :: IsCalendarDateTime cal => CalendarDateTime cal -> TimeZone -> [ZonedDateTime cal] Source #

Return all ZonedDateTime entries for a specific CalendarDateTime in a TimeZone. Normally this would be one, but in the case that a time occurs twice in a zone (i.e. due to daylight savings time change) both would be returned. Also, if the time does not occur at all, an empty list will be returned. This method allows the user to choose exactly what to do in the case of ambigiuty.

resolve :: IsCalendarDateTime cal => (ZonedDateTime cal -> ZonedDateTime cal -> ZonedDateTime cal) -> (ZonedDateTime cal -> ZonedDateTime cal -> ZonedDateTime cal) -> CalendarDateTime cal -> TimeZone -> ZonedDateTime cal Source #

Takes two functions to determine how to resolve a CalendarDateTime to a ZonedDateTime in the case of ambiguity or skipped times. The first function is for the ambigous case and is past the first matching ZonedDateTime, followed by the second match. The second function is for the case that the CalendarDateTime doesn't exist in the TimeZone (e.g. in a spring-forward situation, there will be a missing hour), the first ZonedDateTime will be the the last time before the gap and the second will be the first time after the gap.

Exceptions