t.format("D MMM YYYY") gives 3 Jun 2024.
Under fr_FR it gives 3 juin 2024, and under
de_DE, 3 Juni 2024. Month and weekday names
shipped in 0.20.0, in thirteen languages, and sys.locales()
names what ships.
time.format gained MMM and
MMMM for months, ddd and dddd for
weekdays, and A and a for the AM/PM marker,
which is what h and hh were waiting on. The
render layer gained matching components, so a template can reach the
same names:
@{d:month.short} @{d:day}, @{d:year}
@{d:weekday}
One rule covers all of them: a formatter names a field, and
.short is the only modifier. Both surfaces read the same
table, so t.format("MMMM") and @{d:month}
cannot disagree about what June is called. A locale SCUA does not carry
falls back to English rather than failing.
#Date order now follows the region
Date order follows the region now, not just the language.
en_GB, en_AU, en_NZ,
en_IE, en_IN and en_ZA are
day-first; en_US and a bare en are
month-first, as before. Every non-English locale was already right,
which is why 6/3/2024 under en_GB looked
correct until a reader in the UK took it as the sixth of March.
#money.format now follows the locale
1.234.567,89 € de_DE
1 234 567,89 € fr_FR
€1,234,567.89 en_US
Separator, decimal point and symbol placement all follow the run
locale. Per-currency minor units are unchanged, so JPY still renders
with no decimals. Under the neutral default and en_US the
output is byte-identical to 0.19, so if you have never set a locale
nothing about your program moved.
Money values can be taken apart, too:
money.amount(m)
money.code(m)
money.of(money.amount(m), money.code(m)) gives back
exactly what you started with, at the original scale, including for
zero-decimal currencies like JPY and three-decimal ones like KWD. Use
those instead of parsing a formatted string, where $ covers
USD, CAD and AUD alike and tells you nothing about which one you
have.
#What SCUA knows about a locale
SCUA carries a fixed set of locale data, and the reference now lists it both ways, so you can tell at a glance whether you need a package for something.
It has month and weekday names and their abbreviations, the order a date's fields go in, number separators and grouping, and where a currency symbol sits.
It does not have language-correct sorting, ordinals like
1st, numbers written out as words, accounting or
engineering number formats, timezone display names like "Pacific
Standard Time", or transliteration between scripts. Those are open-ended
and large, and they belong in a package or in the host application.
Timezones are a separate thing from the list above, and worth
spelling out. --tz takes a numeric offset:
--tz=+02:00, --tz=+05:45, or
--tz=UTC. IANA zone names like Europe/Berlin
are not accepted, so a program that starts from one has to turn it into
an offset itself.
The locale
how-to covers --locale and --tz in full,
including --locale=host --tz=host for picking both up from
the machine.