Skip to main content

Nepali Date API

Project description

Nepali Date (Bikram Sambat B.S) API

The API similar to datetime.date() that works on the BS date instead of AD.

Installation

You can install the Nepali Date from PyPI: pip install nepali-date

How to use

BS Date today

from nepali_date import NepaliDate

# print today BS date
print(NepaliDate.today())

Creating NepaliDate instance

from nepali_date import NepaliDate

my_birthday = NepaliDate(2051, 10, 1)
# or
my_birthday = NepaliDate('2051', '10', '1')

Adding/Subtracting datetime.timedelta to NepaliDate instance

import datetime
from nepali_date import NepaliDate

my_birthday = NepaliDate(2051, 10, 1)
hundred_days_after_my_birthday = my_birthday + datetime.timedelta(days=100)
hundred_days_before_my_birthday = my_birthday - datetime.timedelta(days=100)

Converting datetime.date to NepaliDate or vice-versa

import datetime

from nepali_date import NepaliDate

my_birthday_in_ad = datetime.date(1995, 10, 15)
my_birthday_in_bs = NepaliDate.to_nepali_date(my_birthday_in_ad)

my_birthday = NepaliDate(2051, 10, 1)
my_birthday_in_ad = my_birthday.to_english_date()

Monthly Calendar

Current nepali month calendar

from nepali_date import NepaliDate
NepaliDate.calendar()

Screenshot

Date in isoformat() 'YYYY-MM-DD'

dt = NepaliDate(2076, 4, 2)
print(dt.isoformat())
# outputs 2076-04-02

Date display format

Format Specifier Meaning Example
{:d} Day of the month as a zero-padded decimal number. 01, 02, ..., 32
{:b} Month as abbreviated name. Bai, Jes, ..., Cha
{:B} Month as full name. Baishak, Jestha, ..., Chait
{:m} Month as a zero-padded decimal number. 01, 02, ..., 12
{:y} Year without century as a zero-padded decimal number. 00, 01, ..., 99
{:Y} Year with century as a decimal number. 0001, 0002, ..., 2075, 2076, ..., 9999
dt = NepaliDate(2076, 4, 7)
print("{0:B} {0:d}".format(dt))
# outputs Shrawan 07

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

nepali-date-1.1.0.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

nepali_date-1.1.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file nepali-date-1.1.0.tar.gz.

File metadata

  • Download URL: nepali-date-1.1.0.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.2

File hashes

Hashes for nepali-date-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5bb511b10da4fbbdd5ccd5f246b0a9890977845f0e212d1553e122e6a89986a7
MD5 4ba9fd96c551da0fa6344085eb90da86
BLAKE2b-256 418db2450fbdeeb8c14540ff1670ff7b823492d426ccbfe0b1ede79d41166ec9

See more details on using hashes here.

File details

Details for the file nepali_date-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: nepali_date-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.2

File hashes

Hashes for nepali_date-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20856b885ecaad4e554141ef1af850ec68bc835e86aa0d48e7d80ccea1943f8e
MD5 b051ad4cdce84a1de4b1d6ddc01d760d
BLAKE2b-256 3fe413c2c65bf43739a2a0411cd95ec8a7961a53a17ca739118b07eb642a05a9

See more details on using hashes here.

Supported by

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