A text format for a type
Constructors
MkFormatformatShowM :: t -> Maybe StringShow a value in the format, if representable
formatReadP :: ReadP tRead a value in the format
:: a typeCtrl KGHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05
Moduletime-1.12.2Haskell2010
The contents of this module is liable to change, or disappear entirely. Please let me know if you depend on anything here.
A text format for a type
MkFormatformatShowM :: t -> Maybe StringShow a value in the format, if representable
formatReadP :: ReadP tRead a value in the format
ShowPadded IntegerDefined in time-1.12.2 · Data.Time.Calendar.PrivateShowPadded IntDefined in time-1.12.2 · Data.Time.Calendar.PrivateformatCharacter :: Bool -> Char -> Maybe (FormatOptions -> t -> String)FormatTime CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime DayDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime MonthDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime DayOfWeekDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime DiffTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime NominalDiffTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime UTCTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime UniversalTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime CalendarDiffTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime LocalTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime TimeZoneDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanFormatTime ZonedTimeDefined in time-1.12.2 · Data.Time.Format.Format.Instances · orphanSubstitute various time-related information for each %-code in the string, as per formatCharacter.
The general form is %<modifier><width><alternate><specifier>, where <modifier>, <width>, and <alternate> are optional.
<modifier>glibc-style modifiers can be used before the specifier (here marked as z):
%-zno padding
%_zpad with spaces
%0zpad with zeros
%^zconvert to upper case
%#zconvert to lower case (consistently, unlike glibc)
<width>Width digits can also be used after any modifiers and before the specifier (here marked as z), for example:
%4zpad to 4 characters (with default padding character)
%_12zpad with spaces to 12 characters
<alternate>An optional E character indicates an alternate formatting. Currently this only affects %Z and %z.
%Ezalternate formatting
<specifier>For all types (note these three are done by formatTime, not by formatCharacter):
%%%
%ttab
%nnewline
TimeZoneFor TimeZone (and ZonedTime and UTCTime):
%ztimezone offset in the format
±HHMM
%Eztimezone offset in the format
±HH:MM
%Ztimezone name (or else offset in the format
±HHMM
)
%EZtimezone name (or else offset in the format
±HH:MM
)
LocalTimeFor LocalTime (and ZonedTime and UTCTime and UniversalTime):
%cas
locale
(e.g.
%a %b %e %H:%M:%S %Z %Y
)
TimeOfDayFor TimeOfDay (and LocalTime and ZonedTime and UTCTime and UniversalTime):
%Rsame as
%H:%M
%Tsame as
%H:%M:%S
%Xas
locale
(e.g.
%H:%M:%S
)
%ras
locale
(e.g.
%I:%M:%S %p
)
%Pday-half of day from (
locale
), converted to lowercase,
am
,
pm
%pday-half of day from (
locale
),
AM
,
PM
%Hhour of day (24-hour), 0-padded to two chars,
00
-
23
%khour of day (24-hour), space-padded to two chars,
0
-
23
%Ihour of day-half (12-hour), 0-padded to two chars,
01
-
12
%lhour of day-half (12-hour), space-padded to two chars,
1
-
12
%Mminute of hour, 0-padded to two chars,
00
-
59
%Ssecond of minute (without decimal part), 0-padded to two chars,
00
-
60
%qpicosecond of second, 0-padded to twelve chars,
000000000000
-
999999999999
.
%Qdecimal point and fraction of second, up to 12 second decimals, without trailing zeros. For a whole number of seconds,
%Q
omits the decimal point unless padding is specified.
UTCTime and ZonedTimeFor UTCTime and ZonedTime:
%snumber of whole seconds since the Unix epoch. For times before the Unix epoch, this is a negative number. Note that in
%s.%q
and
%s%Q
the decimals are positive, not negative. For example, 0.9 seconds before the Unix epoch is formatted as
-1.1
with
%s%Q
.
DayOfWeekFor DayOfWeek (and Day and LocalTime and ZonedTime and UTCTime and UniversalTime):
%uday of week number for Week Date format,
1
(= Monday) -
7
(= Sunday)
%wday of week number,
0
(= Sunday) -
6
(= Saturday)
%aday of week, short form (
from
locale
),
Sun
-
Sat
%Aday of week, long form (
from
locale
),
Sunday
-
Saturday
MonthFor Month (and Day and LocalTime and ZonedTime and UTCTime and UniversalTime):
%Yyear, no padding. Note
%0Y
and
%_Y
pad to four chars
%yyear of century, 0-padded to two chars,
00
-
99
%Ccentury, no padding. Note
%0C
and
%_C
pad to two chars
%Bmonth name, long form (
from
locale
),
January
-
December
%b, %hmonth name, short form (
from
locale
),
Jan
-
Dec
%mmonth of year, 0-padded to two chars,
01
-
12
DayFor Day (and LocalTime and ZonedTime and UTCTime and UniversalTime):
%Dsame as
%m/%d/%y
%Fsame as
%Y-%m-%d
%xas
locale
(e.g.
%m/%d/%y
)
%dday of month, 0-padded to two chars,
01
-
31
%eday of month, space-padded to two chars,
1
-
31
%jday of year, 0-padded to three chars,
001
-
366
%fcentury for Week Date format, no padding. Note
%0f
and
%_f
pad to two chars
%Vweek of year for Week Date format, 0-padded to two chars,
01
-
53
%Uweek of year where weeks start on Sunday (as
sundayStartWeek
), 0-padded to two chars,
00
-
53
%Wweek of year where weeks start on Monday (as
mondayStartWeek
), 0-padded to two chars,
00
-
53
The specifiers for DiffTime, NominalDiffTime, CalendarDiffDays, and CalendarDiffTime are semantically
separate from the other types.
Specifiers on negative time differences will generally be negative (think rem rather than mod).
NominalDiffTime and DiffTimeNote that a "minute" of DiffTime is simply 60 SI seconds, rather than a minute of civil time.
Use NominalDiffTime to work with civil time, ignoring any leap seconds.
For NominalDiffTime and DiffTime:
%wtotal whole weeks
%dtotal whole days
%Dwhole days of week
%htotal whole hours
%Hwhole hours of day
%mtotal whole minutes
%Mwhole minutes of hour
%stotal whole seconds
%Estotal seconds, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,
%Es
omits the decimal point unless padding is specified.
%0Estotal seconds, with decimal point and <width> (default 12) decimal places.
%Swhole seconds of minute
%ESseconds of minute, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,
%ES
omits the decimal point unless padding is specified.
%0ESseconds of minute as two digits, with decimal point and <width> (default 12) decimal places.
CalendarDiffDaysFor CalendarDiffDays (and CalendarDiffTime):
%ytotal years
%btotal months
%Bmonths of year
%wtotal weeks, not including months
%dtotal days, not including months
%Ddays of week
CalendarDiffTimeFor CalendarDiffTime:
%htotal hours, not including months
%Hhours of day
%mtotal minutes, not including months
%Mminutes of hour
%stotal whole seconds, not including months
%Estotal seconds, not including months, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,
%Es
omits the decimal point unless padding is specified.
%0Estotal seconds, not including months, with decimal point and <width> (default 12) decimal places.
%Swhole seconds of minute
%ESseconds of minute, with decimal point and up to <width> (default 12) decimal places, without trailing zeros. For a whole number of seconds,
%ES
omits the decimal point unless padding is specified.
%0ESseconds of minute as two digits, with decimal point and <width> (default 12) decimal places.
The class of types which can be parsed given a UNIX-style time format string.
substituteTimeSpecifier :: Proxy t -> TimeLocale -> Char -> Maybe StringparseTimeSpecifier :: Proxy t -> TimeLocale -> Maybe ParseNumericPadding -> Char -> ReadP StringGet the string corresponding to the given format specifier.
buildTime :: TimeLocale -> [(Char, String)] -> Maybe tBuilds a time value from a parsed input string.
If the input does not include all the information needed to
construct a complete value, any missing parts should be taken
from 1970-01-01 00:00:00 +0000 (which was a Thursday).
In the absence of %C or %Y, century is 1969 - 2068.
ParseTime CalendarDiffDaysDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime DayDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime MonthDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime DiffTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime NominalDiffTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime UTCTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime UniversalTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime CalendarDiffTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime LocalTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime TimeOfDayDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime TimeZoneDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphanParseTime ZonedTimeDefined in time-1.12.2 · Data.Time.Format.Parse.Instances · orphan