Copyright | (C) 2017 Jason Johnson |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Jason Johnson <jason.johnson.081@gmail.com> |
Stability | experimental |
Portability | POSIX, Windows |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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
- data ZonedDateTime cal
- fromCalendarDateTimeLeniently :: (IsCalendar cal, IsCalendarDateTime cal) => CalendarDateTime cal -> TimeZone -> ZonedDateTime cal
- fromCalendarDateTimeStrictly :: (MonadThrow m, IsCalendarDateTime cal) => CalendarDateTime cal -> TimeZone -> m (ZonedDateTime cal)
- fromInstant :: IsCalendarDateTime cal => Instant -> TimeZone -> ZonedDateTime cal
- toCalendarDateTime :: ZonedDateTime cal -> CalendarDateTime cal
- toCalendarDate :: ZonedDateTime cal -> CalendarDate cal
- toLocalTime :: ZonedDateTime cal -> LocalTime
- inDst :: ZonedDateTime cal -> Bool
- zoneAbbreviation :: ZonedDateTime cal -> String
- year :: IsCalendar cal => ZonedDateTime cal -> Year
- month :: IsCalendar cal => ZonedDateTime cal -> Month cal
- day :: IsCalendar cal => ZonedDateTime cal -> DayOfMonth
- hour :: IsCalendar cal => ZonedDateTime cal -> Hour
- minute :: IsCalendar cal => ZonedDateTime cal -> Minute
- second :: IsCalendar cal => ZonedDateTime cal -> Second
- nanosecond :: IsCalendar cal => ZonedDateTime cal -> Nanosecond
- fromCalendarDateTimeAll :: IsCalendarDateTime cal => CalendarDateTime cal -> TimeZone -> [ZonedDateTime cal]
- resolve :: IsCalendarDateTime cal => (ZonedDateTime cal -> ZonedDateTime cal -> ZonedDateTime cal) -> (ZonedDateTime cal -> ZonedDateTime cal -> ZonedDateTime cal) -> CalendarDateTime cal -> TimeZone -> ZonedDateTime cal
- data DateTimeDoesNotExistException
- data DateTimeAmbiguousException
Types
data ZonedDateTime cal Source #
A CalendarDateTime in a specific time zone. A ZonedDateTime
is global and maps directly to a single Instant
.
Instances
Show (ZonedDateTime cal) Source # | |
Defined in Data.HodaTime.ZonedDateTime.Internal showsPrec :: Int -> ZonedDateTime cal -> ShowS # show :: ZonedDateTime cal -> String # showList :: [ZonedDateTime cal] -> ShowS # | |
Eq (ZonedDateTime cal) Source # | |
Defined in Data.HodaTime.ZonedDateTime.Internal (==) :: ZonedDateTime cal -> ZonedDateTime cal -> Bool # (/=) :: ZonedDateTime cal -> ZonedDateTime cal -> Bool # |
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
toCalendarDateTime :: ZonedDateTime cal -> CalendarDateTime cal Source #
Return the CalendarDateTime
represented by this ZonedDateTime
.
toCalendarDate :: ZonedDateTime cal -> CalendarDate cal Source #
Return the CalendarDate
represented by this ZonedDateTime
.
toLocalTime :: ZonedDateTime cal -> LocalTime Source #
Return the LocalTime
represented by this ZonedDateTime
.
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.
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
data DateTimeDoesNotExistException Source #
Instances
data DateTimeAmbiguousException Source #