Skip to main content

Python BS date conversion utility

Project description

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 ✌

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybsdate-0.3.2.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

pybsdate-0.3.2-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pybsdate-0.3.2.tar.gz.

File metadata

  • Download URL: pybsdate-0.3.2.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pybsdate-0.3.2.tar.gz
Algorithm Hash digest
SHA256 f61f0f46952e5b57bca4f7b491d3b10d3c1deebf5e9a350296e259e450633e82
MD5 fba362a196448662ef06d05339989a8e
BLAKE2b-256 e070e5e9a7660c9605f219b397ce94654e452088c696e54ce48e5c0e209961a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybsdate-0.3.2.tar.gz:

Publisher: python-publish.yml on SushilShrestha/pyBSDate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybsdate-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: pybsdate-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for pybsdate-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 51f5929bf0e224d754579a1153fddb78a2b0404c2457553ae5c97a9bb087b85a
MD5 a86ab21769a7459fecef23fec2d27913
BLAKE2b-256 20b34260ceb29e0047a3ab1348354345ec21ba17db7a25eb728dd7e9a5dc4fa5

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybsdate-0.3.2-py3-none-any.whl:

Publisher: python-publish.yml on SushilShrestha/pyBSDate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page