Skip to main content

pyBSDate

Library to convert BS date to AD date.

PyPI PyPI - Python Version PyPI - Downloads GitHub license

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:

  1. Get a copy of the project. Download zip of the project or clone this repo:
git clone https://github.com/SushilShrestha/pyBSDate
  1. 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

  1. Fork it (https://github.com/SushilShrestha/pyBSDate/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. 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)

Source distribution for pyBSDate 0.3.2
File Size Uploaded
pybsdate-0.3.2.tar.gz 12.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyBSDate 0.3.2
File Interpreter ABI Platform
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 log

Release 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

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

1 release file

0.3.0

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page