Skip to main content

A lightweight Python library for Nepali BS/AD date conversion and calendar utilities

Project description

Samaya - Nepali Date and Time

A lightweight Python library for BS/AD date conversion and calendar utilities.

Features

  • Convert dates between Gregorian (AD) and Nepali (BS) calendars
  • Get current date and time in both AD and BS formats with Nepal timezone
  • Lightweight with minimal dependencies (only pytz)
  • Support for BS years 2000-2099

Installation

Install from PyPI:

pip install samaya

Or install locally in development mode:

git clone https://github.com/bhaveshadhikari/samaya.git
cd samaya
pip install -e .

Usage

Basic Date Conversion

from samaya import ad_to_bs, bs_to_ad

# Convert AD to BS
bs_date = ad_to_bs('2025-10-02')
print(bs_date)  # Output: 2082-6-17

# Convert BS to AD
ad_date = bs_to_ad('2082-06-17')
print(ad_date)  # Output: 2025-10-2

Get Current Date and Time

from samaya import datetime_now

dt = datetime_now()
print(dt.ad_date)   # Gregorian date (e.g., 2025-10-02)
print(dt.bs_date)   # Nepali date (e.g., 2082-06-17)
print(dt.time)      # Current time in Nepal timezone
print(dt.weekday)   # Day of week (e.g., Thursday)

API Reference

ad_to_bs(ad_date: str) -> str

Convert a Gregorian date to Nepali date.

  • Parameters: ad_date - Date string in format 'YYYY-MM-DD'
  • Returns: Date string in format 'YYYY-MM-DD' (BS)

bs_to_ad(bs_date: str) -> str

Convert a Nepali date to Gregorian date.

  • Parameters: bs_date - Date string in format 'YYYY-MM-DD'
  • Returns: Date string in format 'YYYY-MM-DD' (AD)

datetime_now() -> DateTimeInfo

Get current date and time in both formats.

  • Returns: DateTimeInfo object with properties:
    • ad_date: Current Gregorian date
    • bs_date: Current Nepali date
    • time: Current time in HH:MM:SS format
    • weekday: Current day of week

Requirements

  • Python >= 3.7
  • pytz >= 2021.1

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

samaya-0.1.1-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file samaya-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: samaya-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.0

File hashes

Hashes for samaya-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d64ba8fe72ef5caebce53395c5e7da54de0b493af57d51f05a60d99ea3edb14
MD5 9b4da49e0f2629f7fb7085cf44ca38b1
BLAKE2b-256 e90b77a9be81de39d12a917b2de66159ff89ed331e2f61c7a791df11d7719097

See more details on using hashes here.

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