Datetime module that operates on top of Bikram Sambat Date & Nepal Time.
Project description
Nepali Datetime (Bikram Sambat Date & Nepal Time)
The package inspired from Python's core datetime package that
operates on top of Bikram Sambat (B.S) Date & Nepal Time (NPT) +05:45.
Supports: Python 3.5+
Basic Usage
# importing
>>> import datetime
>>> import nepali_datetime
# today's date
>>> datetime.date.today()
>>> nepali_datetime.date.today()
# now datetime
>>> datetime.datetime.now()
>>> nepali_datetime.datetime.now()
# creating date object
>>> datetime.date(2020, 9, 4)
>>> nepali_datetime.date(2077, 5, 19)
# creating datetime object
>>> datetime.datetime(2020, 9, 4, 8, 26, 10, 123456)
>>> nepali_datetime.datetime(2077, 5, 19, 8, 26, 10, 123456)
# date/datetime formatting
>>> nepali_datetime.datetime(2077, 5, 19, 8, 26, 10, 123456).strftime("%d %B %Y")
# 19 Bhadau 2077
# datetime parsed from string (strptime)
>>> nepali_datetime.datetime.strptime('2077-09-12', '%Y-%m-%d')
# nepali_datetime.datetime(2077, 9, 12, 0, 0)
# date/datetime formatting with Nepali unicode support
>>> nepali_datetime.date(1977, 10, 25).strftime('%K-%n-%D (%k %N %G)')
# १९७७-१०-२५ (७७ माघ आइतबार)
# datetime.timedelta addition/subtraction
>>> nepali_datetime.date(1990, 5, 10) + datetime.timedelta(days=350)
# nepali_datetime.date(1991, 4, 26)
>>> nepali_datetime.datetime(1990, 5, 10, 5, 10, 20) + datetime.timedelta(hours=3, minutes=15)
# nepali_datetime.date(1990, 5, 10, 8, 25, 20)
# convert B.S to A.D date and vice-versa
>>> nepali_datetime.date(1999, 7, 25).to_datetime_date()
# datetime.date(1942, 11, 10)
>>> nepali_datetime.date.from_datetime_date(datetime.date(1942, 11, 10))
# nepali_datetime.date(1999, 7, 25)
# Bikram Sambat monthly calendar
>>> nepali_datetime.date(2078, 1, 1).calendar()
Baishakh 2078
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
Installation
$ pip install nepali-datetime
Documentation
Complete usage documentations can be found here.
Contribution
Any contributions are most welcome. Do check this guidelines CONTRIBUTING.md for code contribution.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nepali_datetime-1.0.8.4.tar.gz.
File metadata
- Download URL: nepali_datetime-1.0.8.4.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
933af0ae4545ee32bc2cdaeff40aa90c067f0f7c91908350371303c3dd976a6f
|
|
| MD5 |
f221a61632c459fe2f7ca77392fbdcc3
|
|
| BLAKE2b-256 |
c949ee387ca2e04fae93470baf5ae7468a05c76f662208ff9c01a30552cc77f6
|
File details
Details for the file nepali_datetime-1.0.8.4-py3-none-any.whl.
File metadata
- Download URL: nepali_datetime-1.0.8.4-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
13e052447167f8836618b23cc43bb5f3b259380603defdbfe8efe125f06b8462
|
|
| MD5 |
711e42dd048bbfb6ad1f6c03de573a10
|
|
| BLAKE2b-256 |
39a9e655df60bee3fa82c18be0ca007335690ac5058015e7a344fc8c20f20344
|