Skip to main content

Nepali date converting and displaying.

Project description

Nepali

Python package for processing every nepali stuffs

Requirements

Python >= 3

Installation

pip install nepali

NepaliDate

Represents nepali date, converts English date to nepali date and nepali date to english date

from nepali.datetime import NepaliDate  

Creating new object

# object with current date
np_date = NepaliDate()

# object with today's date
np_date = NepaliDate.today()

Object from python's datetime.date

import datetime

date = datetime.date.today()
np_date = NepaliDate.from_date(date)

Set Current date

np_date.setCurrentDate()

Set English date

np_date.setEnDate(2018, 8, 18)

Set Nepali date

np_date.setNpDate(2075, 6, 22)

Nepali date details

np_date.toNpString() # returns nepali date string  
np_date.npYear()  
np_date.npMonth()  
np_date.npDay()  
np_date.weekDay()

English date details

np_date.toEnString() # returns english date string  
np_date.enYear()  
np_date.enMonth()  
np_date.enDay()  
np_date.weekDay()

Difference Days count

np_date.npDateDifference(2070, 10, 8) # returns no of days difference for nepali date.  
np_date.enDateDifference(2017, 10, 8) # returns no of days difference for english date.

Get python's datetime.date

np_date.to_date()

NepaliDateTime

Represents nepali date time

from nepali.datetime import NepaliDateTime  

Creating new object

# object with specific datetime
np_datetime = NepaliDateTime(year, month, day[, hour[, minute[, second]]]) # arguments must be nepali

# object with current datetime
np_datetime = NepaliDateTime.now()

Object from python's datetime.datetime

import datetime

dt = datetime.datetime.now()
np_datetime = NepaliDateTime.from_datetime(dt)

Get NepaliDate object

np_datetime.date()

Get python's datetime.time object

np_datetime.time()

Get python's datetime.datetime object

np_datetime.to_datetime()

HumanizeDateTime

HumanizeDate converts NepaliDateTime to nepali human readable form

from nepali.datetime import HumanizeDateTime  

Creating new object

# object from nepali datetime
ndt = NepaliDateTime.now()
humanize = HumanizeDate(ndt)

# object from python datetime
dt = datetime.datetime.now()
humanize = HumanizeDate(dt)

Get string

humanize.to_str()

Humanize with threshold returns date in nepali characters if more than threshold(in seconds) else returns humanize form

humanize = HumanizeDate(ndt, threshold=60) # 60 seconds

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-0.0.3.tar.gz (5.6 kB view hashes)

Uploaded Source

Built Distribution

nepali-0.0.3-py3-none-any.whl (12.9 kB view hashes)

Uploaded Python 3

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