This module defines the Formatter
types. It is based on the Java's DateTimeFormatter
format.
Text
represents different text formatting styles.
- short: Std.Time.Text
Short form (e.g., "Tue")
- full: Std.Time.Text
Full form (e.g., "Tuesday")
- narrow: Std.Time.Text
Narrow form (e.g., "T")
Instances For
Equations
- Std.Time.instReprText = { reprPrec := Std.Time.reprText✝ }
Equations
- Std.Time.instReprNumber = { reprPrec := Std.Time.reprNumber✝ }
classifyNumberText
classifies the number of pattern letters into either a Number
or Text
.
Equations
- Std.Time.classifyNumberText x = if x < 3 then some (Sum.inl { padding := x }) else Sum.inr <$> Std.Time.Text.classify x
Instances For
Fraction
represents the fraction of a second, which can either be full nanoseconds
or a truncated form with fewer digits.
- nano: Std.Time.Fraction
Nanosecond precision (up to 9 digits)
- truncated: Nat → Std.Time.Fraction
Fewer digits (truncated precision)
Instances For
Equations
- Std.Time.instInhabitedFraction = { default := Std.Time.Fraction.nano }
classify
classifies the number of pattern letters into either a Fraction
. It's used for nano
.
Equations
- Std.Time.Fraction.classify nat = if nat < 9 then some (Std.Time.Fraction.truncated nat) else if nat = 9 then some Std.Time.Fraction.nano else none
Instances For
Year
represents different year formatting styles based on the number of pattern letters.
- twoDigit: Std.Time.Year
Two-digit year format (e.g., "23" for 2023)
- fourDigit: Std.Time.Year
Four-digit year format (e.g., "2023")
- extended: Nat → Std.Time.Year
Extended year format for more than 4 digits (e.g., "002023")
Instances For
Equations
- Std.Time.instReprYear = { reprPrec := Std.Time.reprYear✝ }
Equations
- Std.Time.instInhabitedYear = { default := Std.Time.Year.twoDigit }
ZoneId
represents different time zone ID formats based on the number of pattern letters.
- short: Std.Time.ZoneId
Short form of time zone (e.g., "PST")
- full: Std.Time.ZoneId
Full form of time zone (e.g., "Pacific Standard Time")
Instances For
Equations
- Std.Time.instReprZoneId = { reprPrec := Std.Time.reprZoneId✝ }
ZoneName
represents different zone name formats based on the number of pattern letters and
whether daylight saving time is considered.
- short: Std.Time.ZoneName
Short form of zone name (e.g., "PST")
- full: Std.Time.ZoneName
Full form of zone name (e.g., "Pacific Standard Time")
Instances For
classify
classifies the number of pattern letters and the letter type ('z' or 'v')
into a ZoneName
format.
- For 'z', if less than 4 letters, it returns the short form; if 4 letters, it returns the full form.
- For 'v', if 1 letter, it returns the short form; if 4 letters, it returns the full form.
- Otherwise, it returns none.
Instances For
OffsetX
represents different offset formats based on the number of pattern letters.
The output will vary between the number of pattern letters, whether it's the hour, minute, second,
and whether colons are used.
- hour: Std.Time.OffsetX
Only the hour is output (e.g., "+01")
- hourMinute: Std.Time.OffsetX
Hour and minute without colon (e.g., "+0130")
- hourMinuteColon: Std.Time.OffsetX
Hour and minute with colon (e.g., "+01:30")
- hourMinuteSecond: Std.Time.OffsetX
Hour, minute, and second without colon (e.g., "+013015")
- hourMinuteSecondColon: Std.Time.OffsetX
Hour, minute, and second with colon (e.g., "+01:30:15")
Instances For
Equations
- Std.Time.instReprOffsetX = { reprPrec := Std.Time.reprOffsetX✝ }
OffsetO
represents localized offset text formats based on the number of pattern letters.
- short: Std.Time.OffsetO
Short form of the localized offset (e.g., "GMT+8")
- full: Std.Time.OffsetO
Full form of the localized offset (e.g., "GMT+08:00")
Instances For
OffsetZ
represents different offset formats based on the number of pattern letters (capital 'Z').
- hourMinute: Std.Time.OffsetZ
Hour and minute without colon (e.g., "+0130")
- full: Std.Time.OffsetZ
Localized offset text in full form (e.g., "GMT+08:00")
- hourMinuteSecondColon: Std.Time.OffsetZ
Hour, minute, and second with colon (e.g., "+01:30:15")
Instances For
classify
classifies the number of pattern letters into an OffsetZ
format.
Equations
- Std.Time.OffsetZ.classify 1 = some Std.Time.OffsetZ.hourMinute
- Std.Time.OffsetZ.classify 2 = some Std.Time.OffsetZ.hourMinute
- Std.Time.OffsetZ.classify 3 = some Std.Time.OffsetZ.hourMinute
- Std.Time.OffsetZ.classify 4 = some Std.Time.OffsetZ.full
- Std.Time.OffsetZ.classify 5 = some Std.Time.OffsetZ.hourMinuteSecondColon
- Std.Time.OffsetZ.classify num = none
Instances For
The Modifier
inductive type represents various formatting options for date and time components,
matching the format symbols used in date and time strings.
These modifiers can be applied in formatting functions to generate custom date and time outputs.
- G: Std.Time.Text → Std.Time.Modifier
G
: Era (e.g., AD, Anno Domini, A). - y: Std.Time.Year → Std.Time.Modifier
y
: Year of era (e.g., 2004, 04, 0002, 2). - u: Std.Time.Year → Std.Time.Modifier
u
: Year (e.g., 2004, 04, -0001, -1). - D: Std.Time.Number → Std.Time.Modifier
D
: Day of year (e.g., 189). - MorL: Std.Time.Number ⊕ Std.Time.Text → Std.Time.Modifier
M
: Month of year as number or text (e.g., 7, 07, Jul, July, J). - d: Std.Time.Number → Std.Time.Modifier
d
: Day of month (e.g., 10). - Qorq: Std.Time.Number ⊕ Std.Time.Text → Std.Time.Modifier
Q
: Quarter of year as number or text (e.g., 3, 03, Q3, 3rd quarter). - w: Std.Time.Number → Std.Time.Modifier
w
: Week of week-based year (e.g., 27). - W: Std.Time.Number → Std.Time.Modifier
W
: Week of month (e.g., 4). - E: Std.Time.Text → Std.Time.Modifier
E
: Day of week as text (e.g., Tue, Tuesday, T). - eorc: Std.Time.Number ⊕ Std.Time.Text → Std.Time.Modifier
e
: Localized day of week as number or text (e.g., 2, 02, Tue, Tuesday, T). - F: Std.Time.Number → Std.Time.Modifier
F
: Aligned week of month (e.g., 3). - a: Std.Time.Text → Std.Time.Modifier
a
: AM/PM of day (e.g., PM). - h: Std.Time.Number → Std.Time.Modifier
h
: Clock hour of AM/PM (1-12) (e.g., 12). - K: Std.Time.Number → Std.Time.Modifier
K
: Hour of AM/PM (0-11) (e.g., 0). - k: Std.Time.Number → Std.Time.Modifier
k
: Clock hour of day (1-24) (e.g., 24). - H: Std.Time.Number → Std.Time.Modifier
H
: Hour of day (0-23) (e.g., 0). - m: Std.Time.Number → Std.Time.Modifier
m
: Minute of hour (e.g., 30). - s: Std.Time.Number → Std.Time.Modifier
s
: Second of minute (e.g., 55). - S: Std.Time.Fraction → Std.Time.Modifier
S
: Fraction of second (e.g., 978). - A: Std.Time.Number → Std.Time.Modifier
A
: Millisecond of day (e.g., 1234). - n: Std.Time.Number → Std.Time.Modifier
n
: Nanosecond of second (e.g., 987654321). - N: Std.Time.Number → Std.Time.Modifier
N
: Nanosecond of day (e.g., 1234000000). - V: Std.Time.Modifier
V
: Time zone ID (e.g., America/Los_Angeles, Z, -08:30). - z: Std.Time.ZoneName → Std.Time.Modifier
z
: Time zone name (e.g., Pacific Standard Time, PST). - O: Std.Time.OffsetO → Std.Time.Modifier
O
: Localized zone offset (e.g., GMT+8, GMT+08:00, UTC-08:00). - X: Std.Time.OffsetX → Std.Time.Modifier
X
: Zone offset with 'Z' for zero (e.g., Z, -08, -0830, -08:30). - x: Std.Time.OffsetX → Std.Time.Modifier
x
: Zone offset without 'Z' (e.g., +0000, -08, -0830, -08:30). - Z: Std.Time.OffsetZ → Std.Time.Modifier
Z
: Zone offset with 'Z' for UTC (e.g., +0000, -0800, -08:00).
Instances For
Equations
- Std.Time.instReprModifier = { reprPrec := Std.Time.reprModifier✝ }
Equations
- Std.Time.instInhabitedModifier = { default := Std.Time.Modifier.G default }
The part of a formatting string. A string is just a text and a modifier is in the format described in
the Modifier
type.
- string: String → Std.Time.FormatPart
A string literal.
- modifier: Std.Time.Modifier → Std.Time.FormatPart
A modifier that renders some data into text.
Instances For
Equations
The format of date and time string.
Equations
Instances For
If the format is aware of some timezone data it parses or if it parses any timezone.
- only: Std.Time.TimeZone → Std.Time.Awareness
The format only parses a single timezone.
- any: Std.Time.Awareness
The format parses any timezone.
Instances For
Equations
- One or more equations did not get rendered due to their size.
A specification on how to format a data or parse some string.
- string : Std.Time.FormatString
The format that is not aware of the timezone.
Instances For
Equations
- Std.Time.instReprGenericFormat = { reprPrec := Std.Time.reprGenericFormat✝ }
Parses a short value of a Month.Ordinal
Instances For
Constructs a new GenericFormat
specification for a date-time string. Modifiers can be combined to create
custom formats, such as "YYYY, MMMM, D".
Equations
- Std.Time.GenericFormat.spec input = do let string ← Std.Time.specParser✝.run input pure { string := string }
Instances For
Builds a GenericFormat
from the input string. If parsing fails, it will panic
Instances For
Formats a DateTime
value into a string using the given GenericFormat
.
Instances For
Parser for a format with a builder.
Equations
- Std.Time.GenericFormat.builderParser format func = Std.Time.GenericFormat.builderParser.go format func
Instances For
Instances For
Parses the input string into a ZoneDateTime
.
Instances For
Parses the input string into a ZoneDateTime
and panics if its wrong.
Instances For
Parses an input string using a builder function to produce a value.
Instances For
Parses an input string using a builder function, panicking on errors.
Instances For
Formats the date using the format into a String, using a getInfo
function to get the information needed to build the String
.
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Std.Time.GenericFormat.formatGeneric.go getInfo data (Std.Time.FormatPart.string val :: xs) = Std.Time.GenericFormat.formatGeneric.go getInfo (data ++ val) xs
- Std.Time.GenericFormat.formatGeneric.go getInfo data [] = some data
Instances For
Constructs a FormatType
function to format a date into a string using a GenericFormat
.
Equations
- format.formatBuilder = Std.Time.GenericFormat.formatBuilder.go "" format.string
Instances For
Equations
- One or more equations did not get rendered due to their size.
- Std.Time.GenericFormat.formatBuilder.go data (Std.Time.FormatPart.string val :: xs) = Std.Time.GenericFormat.formatBuilder.go (data ++ val) xs
- Std.Time.GenericFormat.formatBuilder.go data [] = data
Instances For
Typeclass for formatting and parsing values with the given format type.
- format : (fmt : f) → typ String fmt
Converts a format
f
into a string. Parses a string into a format using the provided format type
f
.