尼泊尔进程的python包

nepali的Python项目详细描述


尼泊尔语

python包,用于处理每种尼泊尔材料

要求

Python >= 3

安装

pip install nepali

功能

  1. 英语到尼泊尔语,尼泊尔语到英语日期转换
  2. 尼泊尔文字

尼泊尔日期

表示尼泊尔日期,将英文日期转换为尼泊尔日期,将尼泊尔日期转换为英文日期

fromnepali.datetimeimportNepaliDate

创建新对象

# object with current datenp_date=NepaliDate()# object with today's datenp_date=NepaliDate.today()

来自python的datetime.date的对象

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.

get python的datetime.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()

来自python的datetime.datetime的对象

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

get nepalidate对象

np_datetime.date()

get python的datetime.time对象

np_datetime.time()

get python的datetime.datetime对象

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

timedelta操作

ndt=NepaliDateTime.now()print(ndt+datetime.timedelta(hours=5))print(ndt-datetime.timedelta(hours=5))

人性化时间

HumanizeDate将尼泊尔时间转换为尼泊尔人可读形式

fromnepali.datetimeimportHumanizeDateTime

创建新对象

# object from nepali datetimendt=NepaliDateTime.now()humanize=HumanizeDateTime(ndt)# object from python datetimedt=datetime.datetime.now()humanize=HumanizeDateTime(dt)

get字符串

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}}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java JavaFX触控事件未触发Ubuntu 20.04触控笔记本电脑   java如何在AWT中关闭窗口?   java Dagger 2:注入具有构造函数参数的成员   创建对象的Java调用类   对象我想在A.java中添加两个数字,并在B.java中打印结果(如何?)   java如何使用AWS SDK for Android从数字海洋空间下载图像?   java Facebook sdk 4.0.1无法使用Android studio获取某些字段   4分钟后web应用程序(Angular 8和Rest API)中的java自动会话超时   在Eclipse for Java EE developers edition中禁用HTML警告   java按字母顺序排列字符串我错过了什么明显的东西吗?   java在Jshell中println和printf有什么不同