尼泊尔进程的python包
nepali的Python项目详细描述
尼泊尔语
python包,用于处理每种尼泊尔材料
要求
Python >= 3
安装
pip install nepali
功能
- 英语到尼泊尔语,尼泊尔语到英语日期转换
- 尼泊尔文字
尼泊尔日期
表示尼泊尔日期,将英文日期转换为尼泊尔日期,将尼泊尔日期转换为英文日期
fromnepali.datetimeimportNepaliDate
创建新对象
# object with current datenp_date=NepaliDate()# object with today's datenp_date=NepaliDate.today()
来自python的datetime.date的对象
设置当前日期 设置英文日期 设置尼泊尔日期 尼泊尔日期详细信息 英文日期详细信息 差异天数计数 get python的datetime.date 表示尼泊尔日期时间 创建新对象 来自python的datetime.datetime的对象 get nepalidate对象 get python的datetime.time对象 get python的datetime.datetime对象 日期字符串格式 timedelta操作 HumanizeDate将尼泊尔时间转换为尼泊尔人可读形式 创建新对象 get字符串 具有阈值的人性化
如果超过阈值(以秒为单位),则以尼泊尔字符返回日期,否则返回人性化表单 将 在您的模板中importdatetimedate=datetime.date.today()np_date=NepaliDate.from_date(date)
np_date.setCurrentDate()
np_date.setEnDate(2018,8,18)
np_date.setNpDate(2075,6,22)
np_date.toNpString()# returns nepali date string np_date.npYear()np_date.npMonth()np_date.npDay()np_date.weekDay()
np_date.toEnString()# returns english date string np_date.enYear()np_date.enMonth()np_date.enDay()np_date.weekDay()
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.
np_date.to_date()
尼泊尔时间
fromnepali.datetimeimportNepaliDateTime
# object with specific datetimenp_datetime=NepaliDateTime(year,month,day[,hour[,minute[,second]]])# arguments must be nepali# object with current datetimenp_datetime=NepaliDateTime.now()
importdatetimedt=datetime.datetime.now()np_datetime=NepaliDateTime.from_datetime(dt)
np_datetime.date()
np_datetime.time()
np_datetime.to_datetime()
npDateTime=NepaliDateTime.now()print(npDateTime.strftime('%a %A %w %d %b %B %m %y %Y %H %I %p %M %S'))print(npDateTime.strftime_en('%a %A %w %d %b %B %m %y %Y %H %I %p %M %S'))
बुध बुधबार ३ २६ मंसिर मंसिर ०८ ७५ २०७५ ११ ११ शुभप्रभात ०६ १३
Wed Wednesday 3 26 Mangsir Mangsir 08 75 2075 11 11 AM 06 13
ndt=NepaliDateTime.now()print(ndt+datetime.timedelta(hours=5))print(ndt-datetime.timedelta(hours=5))
人性化时间
fromnepali.datetimeimportHumanizeDateTime
# object from nepali datetimendt=NepaliDateTime.now()humanize=HumanizeDateTime(ndt)# object from python datetimedt=datetime.datetime.now()humanize=HumanizeDateTime(dt)
humanize.to_str()
humanize=HumanizeDateTime(ndt,threshold=60)# 60 secondshumanize.to_str()# custom format after thresholdhumanize=HumanizeDateTime(ndt,threshold=60,format='%Y-%m-%d')# 60 secondshumanize.to_str()
对于django模板
'nepali'
添加到INSTALLED_APPS
设置中。INSTALLED_APPS=[...'nepali',...]
{%loadnepalidatetime%}
{%nepalinow%}
{%nepalinow'%Y-%m-%d'%}
{{datetimeobj|nepalidate:"%Y-%m-%d"}}
{{datetimeobj|nepalihumanize}}
推荐PyPI第三方库