NAME

Time::Keeper::Natural::Numbers - number words from CLDR's spellout rules

VERSION

Version 0.02

SYNOPSIS

my $nw = Time::Keeper::Natural::Numbers->for('fr');
$nw->read('vingt-et-un');          # 21
$nw->read('vingt et un');          # 21
$nw->ordinal('troisième');         # 3
$nw->day('1er');                   # 1
Time::Keeper::Natural::Numbers->locales;

DESCRIPTION

The words for the whole numbers 0 to 99, and the ordinals 1 to 31, of the locales whose CLDR data has spellout rules: about ninety. They are made once, when the distribution is built, by running CLDR's rules forward (tools/numbercompile), so every form a locale's rules can write is here, its genders and cases among them ("одна", "одного", "одной" are all 1), and nothing that the rules do not write. English adds one hand-written row, "a" and "an" for 1, so "in a week" reads. The ordinals in digits that a day of the month is written with, "15th", "1er", "1.º", "第15", come the same way from the locales' %digits-ordinal rules, with CLDR's ordinal plural rules deciding "1st" from "11th"; about forty locales have them. A locale with no spellout rules reads digits only, in any script, as it always did.

A word is read in lower case, with any run of spaces as one, and with its hyphens or with spaces in their place, so "twenty-one" and "twenty one" are both 21, and French "vingt-et-un" and "vingt et un" both 21. No other spelling is read: "vingt-et-un" in the 1990 spelling is what CLDR writes, and a spelling it does not write is not in the table.

METHODS

for

The number words of a locale, from the nearest locale in its chain that has rules (fr-CA reads fr's), or undef.

read

The whole number a text is, 0 to 99, or undef.

ordinal

The number an ordinal word is, 1 to 31, or undef.

day

The day of the month a digit ordinal is, 1 to 31 ("15th", "1er"), or undef.

cardinals

The words and their numbers, as a list of pairs.

ordinals

The ordinal words and their numbers.

days

The digit ordinals and their numbers.

code

The locale whose rules were read.

locales

The locales that have number words.

chain

The codes tried for a locale, its own first.

dir

Where the words are, one file a locale: beside the module once installed, or the distribution's share/numbers when run from its tree. A locale with no file in its chain has no number words, and finding that out reads nothing.

SEE ALSO

Time::Keeper::Natural, Time::Keeper::Natural::Lexicon.

AUTHOR

LNATION <email@lnation.org>

LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by LNATION.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)