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.Pattern.LocalTime

Description

Patterns for a LocalTime: the standard time layouts (pt, pT, pr) together with the individual field patterns (pHH, phh, pmm, pss, pfrac, ppp and friends) from which custom time patterns are built. The primed variant ppp' takes a Locale for its AM/PM designators.

Synopsis

Standard Patterns

pt :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

Short format pattern. Currently defined as "HH:mm" but should eventually follow the locale

pT :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

Long format pattern. Currently defined as "HH:mm:ss" but should eventually follow locale

pr :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

The round-trippable time pattern, "HH:mm:ss.fffffffff" (nanosecond precision).

Custom Patterns

Used to create specialized patterns

phour :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String Source #

The hour of day in the 24-hour clock as w digits, zero-padded; a width of 1 means no padding. Values 00-23.

pHH :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

The double digit hour of day in the 24-hour clock (phour 2); a value 00-23.

phh :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

The double digit hour of day in the 12-hour clock; a value 01-12. When formatting, the underlying 24-hour value is folded into the 1-12 range (e.g. both 00:00 and 12:00 render as 12). When parsing, the value is combined with an AM/PM designator (pp / ppp) if one is present in the pattern; if no designator is present the value is interpreted as the morning (so 12 parses to midnight).

phh and the AM/PM designators are order independent: each only rewrites its own portion of the hour, so phh <% char ' ' <> ppp and ppp <% char ' ' <> phh both round-trip correctly.

phhSpace :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

The hour of day in the 12-hour clock, space-padded to two characters (the strftime %l convention), e.g. " 3". Like phh it folds the 24-hour value into 1-12 and combines with an AM/PM designator on parse.

pminute :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String Source #

The minute of the hour as w digits, zero-padded; a width of 1 means no padding. Values 00-59.

pmm :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

The double digit minute of the hour (pminute 2); a value 00-59.

psecond :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String Source #

The second of the minute as w digits, zero-padded; a width of 1 means no padding. Values 00-59.

pss :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

The double digit second of the minute (psecond 2); a value 00-59.

pfrac :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String Source #

Fractional seconds of a fixed width n (1-9 digits, since the underlying resolution is nanoseconds). Formatting shows exactly n zero-padded digits (dropping any finer resolution); parsing reads exactly n digits and scales them back up to nanoseconds (so pfrac 3 parses milliseconds). A width outside 1-9 is a programmer error.

NOTE: this is the first pattern that takes a parameter (all the others are nullary values). The parameterized form was chosen because pf/pF are already taken by the standard date/time patterns and because it covers every width uniformly. If parameterized patterns stay rare we may revisit this; a trailing-zero-trimming variant (the NodaTime F specifier) could also be added later.

pp :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

12 hour clock time period designation short form; either A or P. See ppp for the long form.

ppp :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String Source #

12 hour clock time period designation full form; either AM or PM. When parsing, this only sets whether the hour is in the morning or afternoon; combine with phh to parse a full 12-hour time.

ppp' :: HasLocalTime lt => Locale -> Pattern (lt -> lt) (lt -> String) String Source #

12 hour clock time period designator in the given Locale (e.g. the POSIX AM_STR/PM_STR); the locale-aware counterpart to ppp. NOTE: some locales (e.g. German) leave these designators empty, in which case this pattern cannot round-trip; prefer a 24-hour pattern there.

pPeriod :: HasLocalTime lt => (String, String) -> Pattern (lt -> lt) (lt -> String) String Source #

12 hour clock time period designator using an explicit (am, pm) pair, instead of the built-in AM/PM literals. This is the calendar-agnostic core behind the locale-aware ppp'. Parsing matches either designator case-insensitively (PM tried first); as with ppp it only sets morning/afternoon, so combine it with phh.

hour' :: HasLocalTime lt => Pattern (TimeInfo -> TimeInfo) (lt -> String) String Source #

minute' :: HasLocalTime lt => Pattern (TimeInfo -> TimeInfo) (lt -> String) String Source #

second' :: HasLocalTime lt => Pattern (TimeInfo -> TimeInfo) (lt -> String) String Source #