pyBSDate
Library to convert BS date to AD date.
Python implementation of Date conversion From Bikram Sambat(BS) to English Date(AD) and viceversa. Conversion is done with the help of date mappings. So, conversion limited to 1971-2100 BS.
Installation
If you have pip installed, simply
pip install pyBSDate
OR from source:
- Get a copy of the project. Download zip of the project or clone this repo:
git clone https://github.com/SushilShrestha/pyBSDate
- Open your terminal, navigate to the project folder and type
python setup.py install
Usage
Using functions
# Convert BS Date to AD Date
from pyBSDate import convert_BS_to_AD
ad_date = convert_BS_to_AD(2072, 1, 10)
print(ad_date)
# Convert AD Date to BS
from pyBSDate import convert_AD_to_BS
bs_date = convert_AD_to_BS(2015, 4, 23)
print(bs_date)
Class based wrappers
bsdate and addate classes are available for the date conversion. They inherit from the parent datetime.date class and all the functions are similar to datetime.date class.
Following code is the example of using the class based date.
from pyBSDate import bsdate
ne_date = bsdate(2077, 2, 32)
print(ne_date.strftime("%B %d %Y, %A", lang='ne')) # जेष्ठ ३२ २०७७, आइतबार
en_date = ne_date.addate
print (en_date.strftime("%B %d %Y, %A")) # June 14 2020, Sunday
Two date objects can also be compared
import datetime
from pyBSDate import bsdate, addate
ne_date = bsdate(2077, 2, 32)
en_date = addate(2010, 1, 12)
if ne_date > en_date:
print(ne_date.isoformat(lang='ne'))
Addition or substraction of timedelta is also supported
ne_date = ne_date + datetime.timedelta(days=2)
For detailed information, refer to docs.
Development setup
Running test
python -m unittest discover
Release History
- 0.3.0
- add class based wrapper for date conversion
- update documentations
- 0.2.*
- function based date conversion
Meta
Distributed under the MIT license. See LICENSE for more information.
Date mapping data taken from https://github.com/bahadurbaniya/Date-Converter-Bikram-Sambat-to-English-Date
Contributing
Creating a pull request
- Fork it (https://github.com/SushilShrestha/pyBSDate/fork)
- Create your feature branch (
git checkout -b feature/fooBar) - Commit your changes (
git commit -am 'Add some fooBar') - Push to the branch (
git push origin feature/fooBar) - Create a new Pull Request
Submit a Bug Report
The software might include bugs, if you find one help us improve the software by reporting it as an issue (https://github.com/SushilShrestha/pyBSDate/issues) or send us a pull request with the solution.
Peace ✌
Metadata
Release files for pyBSDate 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pybsdate-0.3.2.tar.gz | 12.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pybsdate-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / pybsdate-0.3.2.tar.gz
| Download URL | pybsdate-0.3.2.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f61f0f46952e5b57bca4f7b491d3b10d3c1deebf5e9a350296e259e450633e82
|
|
BLAKE2b-256 checksum How to use checksums |
e070e5e9a7660c9605f219b397ce94654e452088c696e54ce48e5c0e209961a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 12, 2025.
Transparency logRelease files / pybsdate-0.3.2-py3-none-any.whl
| Download URL | pybsdate-0.3.2-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
51f5929bf0e224d754579a1153fddb78a2b0404c2457553ae5c97a9bb087b85a
|
|
BLAKE2b-256 checksum How to use checksums |
20b34260ceb29e0047a3ab1348354345ec21ba17db7a25eb728dd7e9a5dc4fa5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 12, 2025.
Transparency log