A lightweight Python library for Nepali BS/AD date conversion and calendar utilities
Project description
Nepali Date Converter
A lightweight Python library for Nepali 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 datebs_date: Current Nepali datetime: Current time in HH:MM:SS formatweekday: 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
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 Distributions
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 samaya-0.1.0-py3-none-any.whl.
File metadata
- Download URL: samaya-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3252a2018b448c0e09ad8b7f19b852d1335725dd45eab6f0b690bbfe6c8029f5
|
|
| MD5 |
e352d8e46496fc32f1f60fe2d3c69981
|
|
| BLAKE2b-256 |
e78d70286b24eaeab1f196a8cc77db467db71cc54b41ae32b3952903aa3b103e
|