AD-BS Converter
A Python library for converting Gregorian calendar (AD) dates to Bikram Sambat (BS) dates used in Nepal.
Overview
This library provides functionality to convert dates from the Gregorian calendar (AD) to the Bikram Sambat (BS) calendar system, which is the official calendar of Nepal. The implementation uses a pre-defined lookup table for Nepali calendar data from 1970 BS (1913 AD) to 2082 BS (2026 AD) for accurate conversions.
Features
- Convert AD dates to BS dates
- Get formatted BS date in YYYY-MM-DD format
- Get Nepali month names
- Built-in validation for date ranges
- LRU caching for improved performance
Installation
pip install ad-bs-converter
Usage
Basic Conversion
from datetime import date
from ad_bs_converter import ADToBSConverter
# Create a converter with an AD date
ad_date = date(2023, 5, 15)
converter = ADToBSConverter(ad_date)
# Get the BS date
bs_date = converter.get_bs_date()
print(bs_date) # Output: 2080-2-1
# Get formatted date
formatted_date = converter.get_formatted()
print(formatted_date) # Output: 2080-2-1
# Get Nepali month name
month_name = converter.get_month_name()
print(month_name) # Output: Jestha
Cache Management
The library uses LRU caching to improve performance for repeated conversions.
# Configure cache size when creating a converter
converter = ADToBSConverter(date(2023, 5, 15), cache_size=256)
# Get cache information
cache_info = ADToBSConverter.get_cache_info()
print(cache_info)
# Clear the cache if needed
ADToBSConverter.clear_cache()
Error Handling
The library provides specific error handling for date range validation:
from datetime import date
from ad_bs_converter import ADToBSConverter
from ad_bs_converter.exceptions import ADDateOutOfBoundsError
try:
# Try with a date outside the supported range
converter = ADToBSConverter(date(1900, 1, 1))
except ADDateOutOfBoundsError as e:
print(f"Error: {e}")
Supported Date Range
The converter supports AD dates from approximately 1913 to 2026, corresponding to BS dates from 1970 to 2082.
Documentation
For more detailed documentation including:
- API reference
- Implementation details
- Calendar data sources
Please refer to the github link Aayush Dip Giri.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Metadata
Release files for ad-bs-converter 1.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| ad_bs_converter-1.2.3.tar.gz | 8.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ad_bs_converter-1.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 17.4 kB
Release files / ad_bs_converter-1.2.3.tar.gz
| Download URL | ad_bs_converter-1.2.3.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d8221cb9ffcfcd4513b9d5612c725480bcaebadfda74a412e63df99283e9eda
|
|
BLAKE2b-256 checksum How to use checksums |
7a3840f6e65f9f8b4bb08314b87d3eabb9151baf6ed41a54adb17b20c821b841
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Release files / ad_bs_converter-1.2.3-py3-none-any.whl
| Download URL | ad_bs_converter-1.2.3-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
520f093f7c4b442bf45f580eec69c9a9cf035a09d2f248c781c6d9e4256243dc
|
|
BLAKE2b-256 checksum How to use checksums |
d5395ae3ba5691df6d236e47b348f3a0d029c807e2b8106b1d8120c2030a26a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.1
|
Security for ad-bs-converter 1.2.3
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.