Substitute 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
TimeZone
For 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
)
LocalTime
For LocalTime (and ZonedTime and UTCTime and UniversalTime):
%cas
dateTimeFmt
locale
(e.g.
%a %b %e %H:%M:%S %Z %Y
)
TimeOfDay
For TimeOfDay (and LocalTime and ZonedTime and UTCTime and UniversalTime):
%Rsame as
%H:%M
%Tsame as
%H:%M:%S
%Xas
timeFmt
locale
(e.g.
%H:%M:%S
)
%ras
time12Fmt
locale
(e.g.
%I:%M:%S %p
)
%Pday-half of day from (
amPm
locale
), converted to lowercase,
am
,
pm
%pday-half of day from (
amPm
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 ZonedTime
For 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
.
DayOfWeek
For 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 (
snd
from
wDays
locale
),
Sun
-
Sat
%Aday of week, long form (
fst
from
wDays
locale
),
Sunday
-
Saturday
Month
For 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 (
fst
from
months
locale
),
January
-
December
%b, %hmonth name, short form (
snd
from
months
locale
),
Jan
-
Dec
%mmonth of year, 0-padded to two chars,
01
-
12
Day
For Day (and LocalTime and ZonedTime and UTCTime and UniversalTime):
%Dsame as
%m/%d/%y
%Fsame as
%Y-%m-%d
%xas
dateFmt
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
Duration types
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 DiffTime
Note 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.
CalendarDiffDays
For CalendarDiffDays (and CalendarDiffTime):
%ytotal years
%btotal months
%Bmonths of year
%wtotal weeks, not including months
%dtotal days, not including months
%Ddays of week
CalendarDiffTime
For 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.