| 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 |
Data.HodaTime.Pattern.ZonedDateTime
Description
Patterns for ZonedDateTime.
Formatting, and effectful parsing
Formatting is direct: pZonedDateTime renders a ZonedDateTime as its local date/time plus the zone id.
Parsing cannot use the pure parse, because building a ZonedDateTime is effectful: it has to load the time-zone
rules for the parsed zone id and then resolve the local time (which may be skipped or ambiguous). Use
parseZonedDateTime instead — you supply a zone provider (e.g. timeZone in IO, or a pure lookup) and a
resolver (e.g. fromCalendarDateTimeStrictly). Calling parse on pZonedDateTime is a type error by design;
parseZonedDateTime is the only way to parse one.
Synopsis
- pZonedDateTime :: (IsCalendar cal, Enum (Month cal)) => Pattern (ZonedDateTime cal -> ZonedDateTime cal) (ZonedDateTime cal -> String) String
- parseZonedDateTime :: (MonadThrow m, IsCalendar cal, Enum (Month cal)) => (String -> m TimeZone) -> (CalendarDateTime cal -> TimeZone -> m (ZonedDateTime cal)) -> String -> m (ZonedDateTime cal)
- zonedDateTimePattern :: Pattern (CalendarDateTime cal -> CalendarDateTime cal) (CalendarDateTime cal -> String) String -> (ZonedDateTime cal -> String) -> Pattern (ZonedDateTime cal -> ZonedDateTime cal) (ZonedDateTime cal -> String) String
Standard Patterns
pZonedDateTime :: (IsCalendar cal, Enum (Month cal)) => Pattern (ZonedDateTime cal -> ZonedDateTime cal) (ZonedDateTime cal -> String) String Source #
The ISO-8601 local date/time followed by a space and the (unambiguous) IANA zone id, e.g.
2024-04-23T09:00:00 Europe/Zurich.
Parsing
parseZonedDateTime :: (MonadThrow m, IsCalendar cal, Enum (Month cal)) => (String -> m TimeZone) -> (CalendarDateTime cal -> TimeZone -> m (ZonedDateTime cal)) -> String -> m (ZonedDateTime cal) Source #
Parse a zoned date/time and resolve it to a ZonedDateTime. You supply a zone provider (which loads the
TimeZone for the parsed id — timeZone in IO, or a pure lookup) and a resolver (which turns the local time
into a ZonedDateTime, deciding the skipped/ambiguous cases — e.g. fromCalendarDateTimeStrictly). This is the
only way to parse a ZonedDateTime; the pure parse cannot (it is a type error on pZonedDateTime).
Custom Patterns
Build a (format-only) ZonedDateTime pattern from a CalendarDateTime pattern and a zone-rendering function.
zonedDateTimePattern :: Pattern (CalendarDateTime cal -> CalendarDateTime cal) (CalendarDateTime cal -> String) String -> (ZonedDateTime cal -> String) -> Pattern (ZonedDateTime cal -> ZonedDateTime cal) (ZonedDateTime cal -> String) String Source #
Format a ZonedDateTime using the given CalendarDateTime pattern for the local date/time, followed by the
result of the zone-rendering function (e.g. a leading space and the zone id).
Formatting only: the parse side deliberately fails (see the module note), so the pure
parse cannot silently produce a wrong ZonedDateTime.