Skip to main content

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 0 to 100
  • 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.date or datetime.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 123 or 12.5
  • currency patterns such as Rs. 500, NPR 500, or 500 रुपैयाँ

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

Build release artifacts with:

python -m build
python -m twine check dist/* 

Notes

  • use_bs=True converts Gregorian input into Bikram Sambat output.
  • BS formatting works directly for explicit BS input such as 2080-10-01.
  • The package keeps bsdatetime as a runtime dependency so installed distributions can do AD-to-BS conversion accurately.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nepali_date_numword-0.1.0.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nepali_date_numword-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

Details for the file nepali_date_numword-0.1.0.tar.gz.

File metadata

  • Download URL: nepali_date_numword-0.1.0.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

Hashes for nepali_date_numword-0.1.0.tar.gz
Algorithm Hash digest
SHA256 28426bb62df8f000bcefa07df6bc497b2c7f4a8cb4da1361c5a2596d65aba369
MD5 efdfbdd6c0c91b0cf4235e856aed5062
BLAKE2b-256 f83b154d829ec92f8674b659ff55c9a5d8e2c163f62d33873f1385bf6102fe58

See more details on using hashes here.

Provenance

The following attestation bundles were made for nepali_date_numword-0.1.0.tar.gz:

Publisher: publish.yml on Naearp777/nepali_date_numword

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nepali_date_numword-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nepali_date_numword-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c738d428365554221759d7738610895655ca3ec1d346b50ba351790515c1d0c5
MD5 24aed08fc5aef487bf66485a1da8d758
BLAKE2b-256 009140fbde5c3a7df8d124c433d3cd4fa6440ae7324fcf5d9d96b55f670bd95e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nepali_date_numword-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Naearp777/nepali_date_numword

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page