Formatting of time into a string.
Format a time according to format string
fmt and using a optional
time locale (=
z) are always interpreted as a pattern where unknown letter
patterns are ignored. Any literal text should be quote-escaped i.e. use
to display as
"GMT-07:00" (in the PST time zone). Any characters other then
an ascii letter are displayed as is.
Patterns of 2 letters are zero-padded on the left to always display as 2 digits. Allowed patterns:
Y: the year as a number (without zero padding) (
`YYYY: the year in upto 4 digits (
0203). If the year is smaller than zero or larger than 9999, the year is displayed with 5 or more digits and preprended with an explicit sign (
MM: the month. (
03). In case of an ISO week (
cal-iso-week) or ISO month (
cal-iso-month) calendar, the month is prefixed with
MMMM: name of the month in the specified
DD: the day of the month. (
DDis used and this is an ISO week calendar (
cal-iso-week) just one digit is used for the week day.
DDD: the day of the year. (
d: the ISO day of the week, 1 for Monday ending in 7 for Sunday.
dddd: the day of the week in the current
hh: the hours using a 12-hour clock (with am/pm). (
HH: the hours using a 24-hour clock. (
mm: the minutes. (
ss: the whole seconds. (
aa: AM/PM designation. (
AA: AM/PM designation in upper-case. (
fffffffff: upto 9 digits of a fraction of a second. Starts with a dot. (
FFFFFFFFF: upto 9 digits of a fraction of a second. If not zero, starts with a dot. In contrast to the
fpatterns displays the minimal number of required digits (and is not right-padded with zeros). (
z: timezone offset in hours and minutes separated by a colon. Use
+00:00for UTC time. (
zz: timezone offset in hours and minutes without a separator. Use
+0000for UTC time. (
Z: timezone offset in hours and minutes separated by a colon, use
Zfor UTC time.
ZZ: timezone offset in hours and minutes separated by colon, use an empty string for UTC time.
x: fractional seconds since
YYYYYY: the year in ECMAscript 6 digits, prepended with the sign. (
y: the absolute value of the year as a number (without zero padding). Useful when displaying Julian (
cal-julian) negative years as
10 BCfor example (e.g.
CC: the short or long calendar name. (The short name is empty for the standard ISO calendars).
E: the era name, for example
CEfor the Gregorian calendar.
"...": anything between quotes is displayed as is. (
There are also various forms to display dates and times in a locale specific way.
We give examples in English and Dutch. The lower-case
l variants use short
names for month- and day names.
t: hours and minutes (
tt: hours, minutes, and seconds (
l: a date (
09/29/2016, 29.09.2016) and (
ll: date with month name (
29 September 2016, 29 september 2016) and (
29 Sep 2016, 29 sep 2016)
lll: date with month name and time (
29 September 2016 1:15pm, 29 september 2016 13:15)
llll: date with day name, month name, and time (
Thursday, 29 September 2016 1:15pm) and (
Thu, 29 Sep 2016 1:15pm)
After formatting, any left- or right white space is trimmed. This allows specifiers
"YYYY E C" that display correctly even if the era or calendar name is empty.
For example, to display a time in the standard Internet Message Format
you can use
now().formatstd/time/format/format: (t : time, fmt : string, locale : ?time-locale) -> string("ddd, D MMM Y HH:mm:ss zz") displayed as
"Tue, 27 Sep 2016 06:36:55 -0700" for example.
A standard ISO string can be formatted as,
Show time as a standard Internet Message Format date.
now().show-imfstd/time/format/show-imf: (t : time) -> string returns
"Fri, 9 Oct 2016 11:57:45 -0700".
Show the time as a human readable string in the given
"Thu, 8 Oct 2016, 12:20pm". Uses the
"llll" format string.
Show the date in human readable string in the given
"Thu, 8 Oct 2016". Uses the
"ll" format string.
Show a time as a standard ISO string. Will use automatic week date
or month date format for the
Show a time as a standard ISO date. Will use automatic week date
or month date format for the