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 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.
Metadata
Release files for samaya 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| samaya-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for samaya-0.1.1-py3-none-any.whl |
Release files / samaya-0.1.1-py3-none-any.whl
| Download URL | samaya-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d64ba8fe72ef5caebce53395c5e7da54de0b493af57d51f05a60d99ea3edb14
|
|
BLAKE2b-256 checksum How to use checksums |
e90b77a9be81de39d12a917b2de66159ff89ed331e2f61c7a791df11d7719097
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.0
|
Security for samaya 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.