Calendar
Format
format a Date or UTC Time object as a string
Parse
parse a string to a Date object with respect to a given format string
Calling Sequence
Parameters
Options
Description
Examples
References
Compatibility
Format( d, fmt )
Parse( s, fmt )
d
-
Date; a Date object
s
string; string to parse
fmt
string; (optional) a format string
locale : string; the name of a locale to use
Dates (and Time objects) can be formatted to a string by using the Format( d, fmt ) command.
A string containing date information can be parsed to produce a corresponding Date object by using the Parse( s, fmt ) command.
The format string fmt is a string of free-form text with embedded formatting codes specified in the Unicode Technical Standard #35. Note that literal text in fmt must be quoted with single (forward) quotes (').
For an alternative way to provide format strings, see Calendar[VariantFormat].
The format string fmt is optional. Its default value is the string "yyyy-MM-dd'T'HH:mm:ss zzz".
Use the locale = loc option to control which locale formatting and parsing occurs in. The loc value should be a two-letter language code (E.g., "id" for Indonesian), optionally separated by an underscore character ("_") from a country variant indicates by using a two- or three-letter country code. (E.g., "fr_CA" for Canadian French.)
For some of the examples below to print correctly, you may need special fonts to be installed on your computer.
with⁡Calendar:
s≔Format⁡Today⁡
s≔2024-03-01T05:38:42 UTC
Parse⁡s
<Date: 2024-03-01T05:38:42 GMT>
Format⁡Today⁡,'The day of the week is 'eeee
The day of the week is Friday
s≔Format⁡Today⁡,EEEE, MMMM dd, yyyy GG 'at' hh:mm:ss a
s≔Friday, March 01, 2024 AD at 05:38:42 AM
Parse⁡s,EEEE, MMMM dd, yyyy GG 'at' hh:mm:ss a
t≔Format⁡Now⁡SystemUTCClock
t≔2024-03-01T05:38:42 UTC
Note that the output of Parse is always a Date object; the source of the input string as a formatted Time object is unknown to the Parse command.
Parse⁡t
To use a locale different from the default locale, use the locale= option.
Format⁡Today⁡,EEEE, MMMM dd, yyyy GG, hh:mm:ss a,locale=ja
金曜日, 3月 01, 2024 西暦, 05:38:42 午前
Format⁡Today⁡,EEEE, MMMM dd, yyyy GG 'jam' hh:mm:ss a,locale=id
Jumat, Maret 01, 2024 M jam 05:38:42 AM
s≔Format⁡Today⁡,EEEE, MMMM dd, yyyy GG 'um' hh:mm:ss a,locale=de
s≔Freitag, März 01, 2024 n. Chr. um 05:38:42 AM
Parse⁡s,EEEE, MMMM dd, yyyy GG 'um' hh:mm:ss a,locale=de
s≔Format⁡Date⁡−42,3,15,3,4,5,EEEE, MMMM dd, yyyy GGGGGGG 'jam' hh:mm:ss a,locale=id
s≔Kamis, Maret 15, 0043 SM jam 03:04:05 AM
Parse⁡s,EEEE, MMMM dd, yyyy GGGGGGG 'jam' hh:mm:ss a,locale=id
<Date: 0043-03-15T03:04:05 GMT>
Unicode Technical Standard #35
ISO 639.2
The Calendar[Format] and Calendar[Parse] commands were introduced in Maple 2019.
For more information on Maple 2019 changes, see Updates in Maple 2019.
See Also
Calendar[VariantFormat]
Date
StringTools[FormatTime]
StringTools[ParseTime]
Download Help Document