|
Description
|
|
•
|
The Calendar package has new commands for parsing and formatting Date and Time objects.
|
|
|
Formatting Dates and Times
|
|
•
|
Codes for formatting and parsing are specified according to the Unicode Technical Standard #35, "Unicode Locale Data Markup Language (LDML)", Part 4 (Dates).
|
| (1) |
>
|
Format( Today(), 'locale' = "fr" );
|
| (2) |
>
|
Format( Today(), "yyyy.MM.dd G 'at' HH:mm:ss zzz" );
|
| (3) |
>
|
Format( Today(), "yyyy.MM.dd G 'um' HH:mm:ss zzz", 'locale' = "de" );
|
| (4) |
>
|
Format( Now( SystemUTCClock ), "K:mm a, z", 'locale' = "ja" );
|
>
|
Format( Now( SystemUTCClock ), "hh 'o''clock' a, zzzz" );
|
| (6) |
•
|
Unlike the similar command FormatTime in the StringTools package, the Calendar:-VariantFormat command supports the locale option, allowing you to format dates and times in a locale-sensitive way. Moreover, the Calendar package commands work directly with Date and UTC Time objects.
|
>
|
VariantFormat( Today(), "%c" );
|
| (7) |
>
|
VariantFormat( Today(), "%c", 'locale' = "id" );
|
| (8) |
>
|
fmt := "EEEE, MMMM dd, yyyy GG, hh:mm:ss a":
|
>
|
DocumentTools:-Tabulate( map( loc -> Format( Today(), fmt, ':-locale' = loc ), << "en", "fr", "de" > | < "ks", "ja", "ko" >> ) ):
|
Friday, March 01, 2024 AD, 03:45:49 PM
|
جُمہ, مارٕچ ۰۱, ۲۰۲۴ اے ڈی, ۰۳:۴۵:۴۹ PM
|
vendredi, mars 01, 2024 ap. J.-C., 03:45:49 PM
|
金曜日, 3月 01, 2024 西暦, 03:45:49 午後
|
Freitag, März 01, 2024 n. Chr., 03:45:49 PM
|
금요일, 3월 01, 2024 AD, 03:45:49 오후
|
|
|
|
|
Parsing Dates and Times
|
|
>
|
s := Format( Today(), "EEEE, MMMM dd, yyyy GG, hh:mm:ss a", 'locale' = "id" );
|
| (9) |
>
|
Parse( s, "EEEE, MMMM dd, yyyy GG, hh:mm:ss a", 'locale' = "id" );
|
| (10) |
>
|
s := VariantFormat( Today(), "%c", 'locale' = "de" );
|
| (11) |
>
|
VariantParse( s, "%c", 'locale' = "de" );
|
| (12) |
|
|
|