Skip to content

Numbers, dates and currency

numbers

Number ↔ words, digit conversion, currency, and date verbalization for Odia.

Examples:

>>> from openodia import numbers
>>> numbers.to_words(1234)
'ଏକ ହଜାର ଦୁଇ ଶହ ଚଉତିରିଶ'
>>> numbers.ascii_to_odia("2026")
'୨୦୨୬'
>>> numbers.to_ordinal(3)
'ତୃତୀୟ'

to_words_currency

to_words_currency(
    amount: float | Decimal | int,
    currency: str = "INR",
    scale: NumberingScale = "indian",
) -> str

Verbalize a monetary amount in Odia.

Parameters:

Name Type Description Default
amount float | Decimal | int

Numeric value. Fractional part is rounded to two decimal places (paisa) using banker-friendly half-up rounding.

required
currency str

Currently only "INR" is supported. Defined as a parameter so additional currencies can be added without a breaking change.

'INR'
scale NumberingScale

Numbering scale to use for both rupee and paisa parts.

'indian'

Returns:

Type Description
str

For non-zero rupees and non-zero paisa, "<rupee_words> ଟଙ୍କା <paisa_words> ପଇସା".

str

For zero paisa, the paisa half is omitted. For zero rupees and

str

non-zero paisa, the rupee half is omitted.

Raises:

Type Description
ValueError

If amount is negative or currency is not supported.

Examples:

>>> to_words_currency(1500.50)
'ଏକ ହଜାର ପାଞ୍ଚ ଶହ ଟଙ୍କା ପଚାଶ ପଇସା'
>>> to_words_currency(1)
'ଏକ ଟଙ୍କା'
>>> to_words_currency(0.05)
'ପାଞ୍ଚ ପଇସା'

to_words_date

to_words_date(
    value: date, scale: NumberingScale = "indian"
) -> str

Verbalize a Gregorian date in Odia.

Output format: "<day_ordinal> <month_name>, <year_words>".

Parameters:

Name Type Description Default
value date

A datetime.date (or datetime.datetime).

required
scale NumberingScale

Numbering scale for the year portion.

'indian'

Returns:

Type Description
str

Space-separated Odia string.

Raises:

Type Description
ValueError

If value.year is non-positive.

Examples:

>>> from datetime import date
>>> to_words_date(date(2026, 5, 27))
'ସତାଇଶତମ ମଇ, ଦୁଇ ହଜାର ଛବିଶ'

ascii_to_odia

ascii_to_odia(text: str) -> str

Convert ASCII digits in text to Odia digits. Non-digits pass through.

odia_to_ascii

odia_to_ascii(text: str) -> str

Convert Odia digits in text to ASCII digits. Non-digits pass through.

to_ordinal

to_ordinal(n: int) -> str

Return the ordinal Odia word for the positive integer n.

Ordinals 1..10 use their irregular forms (ପ୍ରଥମ, ଦ୍ୱିତୀୟ, ...). For n ≥ 11 the cardinal word is suffixed with ତମ.

Parameters:

Name Type Description Default
n int

Positive integer.

required

Raises:

Type Description
ValueError

If n is zero or negative.

from_words

from_words(
    words: str, scale: NumberingScale = "indian"
) -> int

Parse an Odia number-words string back to an integer.

The inverse of to_words. Accepts the output produced by this package; tolerates extra whitespace.

Parameters:

Name Type Description Default
words str

Odia number-words string.

required
scale NumberingScale

Must match the scale used to produce words.

'indian'

Returns:

Type Description
int

The integer value.

Raises:

Type Description
ValueError

If a token is not recognised, if scale is invalid, or if words is empty after stripping.

Examples:

>>> from_words("ଏକ ହଜାର ଦୁଇ ଶହ ଚଉତିରିଶ")
1234

to_words

to_words(n: int, scale: NumberingScale = 'indian') -> str

Convert an integer to its Odia word form.

Parameters:

Name Type Description Default
n int

Any integer (positive, zero, or negative).

required
scale NumberingScale

"indian" (default) uses lakh / crore. "short" uses million / billion / trillion.

'indian'

Returns:

Type Description
str

Space-separated Odia words.

Raises:

Type Description
ValueError

If scale is not one of the two supported values.

Examples:

>>> to_words(0)
'ଶୂନ୍ୟ'
>>> to_words(1234)
'ଏକ ହଜାର ଦୁଇ ଶହ ଚଉତିରିଶ'
>>> to_words(1_000_000, scale="short")
'ଏକ ମିଲିୟନ'