Convert numbers and dates into grammatically correct Nepali words.
Project description
nepali-date-numword
nepali-date-numword converts numbers and dates into grammatically correct Nepali words.
It supports Nepali number wording, Gregorian date wording, Bikram Sambat date wording,
currency suffixes, negative values, floats, and a small CLI for everyday use.
Features
- Convert integers using the Nepali numbering system:
सय,हजार,लाख,करोड,अरब - Handle irregular Nepali values from
0to100 - Support negative numbers and floating-point values
- Add currency suffixes like
रुपैयाँ - Convert Gregorian dates into Nepali words
- Convert Bikram Sambat dates into Nepali words
- Convert AD dates to BS output with
use_bs=True - Provide CLI support for numbers and dates
Installation
pip install nepali-date-numword
Python 3.10 or newer is required.
For local development:
pip install -e .[dev]
Quick Usage
from datetime import date
from nepali_date_numword import date_to_words, number_to_words, text_to_words
print(number_to_words(123))
# एक सय तेइस
print(number_to_words(-12.5))
# माइनस बाह्र दशमलव पाँच
print(number_to_words(123, currency=True))
# एक सय तेइस रुपैयाँ
print(date_to_words("2024-01-15", calendar="AD"))
# सन् दुई हजार चौबीस जनवरी पन्ध्र तारिख
print(date_to_words("2080-10-01", calendar="BS"))
# वि.सं. दुई हजार अस्सी माघ एक गते
print(date_to_words(date(2024, 1, 15), calendar="AD", use_bs=True))
# वि.सं. दुई हजार अस्सी माघ एक गते
print(date_to_words("2024-01-15", short=True))
# १५ जनवरी २०२४
print(text_to_words("I paid Rs. 123 on 2024-01-15."))
# I paid एक सय तेइस रुपैयाँ on सन् दुई हजार चौबीस जनवरी पन्ध्र तारिख.
API
number_to_words(number, currency=False)
Convert an integer or floating-point value into Nepali words.
Examples:
number_to_words(0)
number_to_words(100000)
number_to_words(12.5)
number_to_words(123, currency=True)
date_to_words(value, calendar="AD", use_bs=False, short=False)
Convert a Gregorian or Bikram Sambat date into Nepali words.
Accepted input forms:
- ISO string:
"2024-01-15" datetime.dateordatetime.datetime- Tuple:
(2024, 1, 15)
Examples:
date_to_words("2024-01-15", calendar="AD")
date_to_words("2080-10-01", calendar="BS")
date_to_words((2024, 1, 15), calendar="AD", use_bs=True)
text_to_words(text, use_bs=False, include_suffix=True, short_dates=False)
Convert mixed sentences by detecting:
- ISO dates such as
2024-01-15 - plain numbers such as
123or12.5 - currency patterns such as
Rs. 500,NPR 500, or500 रुपैयाँ
Example:
text_to_words("Invoice total is Rs. 123 and due on 2024-01-15.")
CLI
nepali-date-numword 123
nepali-date-numword --currency 123
nepali-date-numword --date 2024-01-15
nepali-date-numword --date 2024-01-15 --bs
nepali-date-numword --date 2080-10-01 --calendar BS
nepali-date-numword --date 2024-01-15 --short
nepali-date-numword --text "I paid Rs. 123 on 2024-01-15."
Development
Run tests with:
pytest
Notes
use_bs=Trueconverts Gregorian input into Bikram Sambat output.- BS formatting works directly for explicit BS input such as
2080-10-01. - The package keeps
bsdatetimeas a runtime dependency so installed distributions can do AD-to-BS conversion accurately.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nepali_date_numword-0.1.1.tar.gz.
File metadata
- Download URL: nepali_date_numword-0.1.1.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97ff54ae0cb48f5093be540d6f3fc0fb383cd47f8f5ceff21900d873e5d384b2
|
|
| MD5 |
49957748938aa4bc6543922a07b60ed7
|
|
| BLAKE2b-256 |
c4036df8e7c3338d859b01d70da749fb6e9deff81eee0ec3196c24068d7fd100
|
Provenance
The following attestation bundles were made for nepali_date_numword-0.1.1.tar.gz:
Publisher:
publish.yml on Naearp777/nepali_date_numword
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nepali_date_numword-0.1.1.tar.gz -
Subject digest:
97ff54ae0cb48f5093be540d6f3fc0fb383cd47f8f5ceff21900d873e5d384b2 - Sigstore transparency entry: 1386669789
- Sigstore integration time:
-
Permalink:
Naearp777/nepali_date_numword@9f3275aa22a532608b8290958c678abd3a26e4ba -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Naearp777
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f3275aa22a532608b8290958c678abd3a26e4ba -
Trigger Event:
release
-
Statement type:
File details
Details for the file nepali_date_numword-0.1.1-py3-none-any.whl.
File metadata
- Download URL: nepali_date_numword-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4336a760de816192e6b03c89ee70590b0e772149449d382795fb00f96772cd73
|
|
| MD5 |
99caf3005aac51e6be0fcc7cf03ada74
|
|
| BLAKE2b-256 |
1c4757a44169410ead8ea64cd1c27954c264eff7f45da7c1044bf94854a007ce
|
Provenance
The following attestation bundles were made for nepali_date_numword-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Naearp777/nepali_date_numword
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
nepali_date_numword-0.1.1-py3-none-any.whl -
Subject digest:
4336a760de816192e6b03c89ee70590b0e772149449d382795fb00f96772cd73 - Sigstore transparency entry: 1386670028
- Sigstore integration time:
-
Permalink:
Naearp777/nepali_date_numword@9f3275aa22a532608b8290958c678abd3a26e4ba -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/Naearp777
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9f3275aa22a532608b8290958c678abd3a26e4ba -
Trigger Event:
release
-
Statement type: