| 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.LocalTime
Contents
Description
Synopsis
- pt :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- pT :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- pr :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- phour :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String
- pHH :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- phh :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- phhSpace :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- pminute :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String
- pmm :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- psecond :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String
- pss :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- pfrac :: HasLocalTime lt => Int -> Pattern (lt -> lt) (lt -> String) String
- pp :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- ppp :: HasLocalTime lt => Pattern (lt -> lt) (lt -> String) String
- ppp' :: HasLocalTime lt => Locale -> Pattern (lt -> lt) (lt -> String) String
- pPeriod :: HasLocalTime lt => (String, String) -> Pattern (lt -> lt) (lt -> String) String
- hour' :: HasLocalTime lt => Pattern (TimeInfo -> TimeInfo) (lt -> String) String
- minute' :: HasLocalTime lt => Pattern (TimeInfo -> TimeInfo) (lt -> String) String
- second' :: HasLocalTime lt => Pattern (TimeInfo -> TimeInfo) (lt -> String) String
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 (); a value 00-23.phour 2
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
and phh <% char ' ' <> ppp both round-trip correctly.ppp <% char ' ' <> phh
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 (); a value 00-59.pminute 2
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 (); a value 00-59.psecond 2
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 parses milliseconds). A width outside 1-9 is a programmer error.pfrac 3
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.
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.