用于为快速日期操作和丰富功能生成业务日期的python库。
businessdate的Python项目详细描述
用于生成继承的业务日期的快速、高效的python库 用于快速日期操作。典型银行业务方法 提供如公休日调整,日数分数。 除了日期之外,通用业务期间还提供创建时间段的功能,如 “10y”、“3个月”或“2b”。期间可以很容易地添加到业务日期。
示例用法
fromdatetimeimportdatefrombusinessdateimportBusinessDate,BusinessPeriod>>>BusinessDate(20140101).add_days(10)20140111>>>BusinessPeriod('1Y').add_months(3)1Y3M>>>BusinessDate(20140101)+BusinessPeriod('1Y3M')20150301
安装
最新的稳定版本始终可以通过pip安装或更新:
$ pip install businessdate
如果上述操作失败,请尝试轻松安装:
$ easy_install businessdate
示例
# Simplest example possible>>>fromdatetimeimportdate>>>frombusinessdateimportBusinessDate,BusinessPeriod,BusinessRange,BusinessSchedule>>>BusinessDate.from_date(date(2014,1,1))==BusinessDate(20140101)True>>>BusinessDate(20140101)+'1y6m'20150701>>>BusinessDate(20140101).adjust_follow()20140102>>>BusinessPeriod('1Y')==BusinessPeriod(years=1)True>>>BusinessPeriod('1Y')1Y>>>BusinessPeriod('1Y').add_businessdays(3)1Y3B>>>BusinessPeriod('1Y')+'1y6m'1Y6M>>>sd=BusinessDate(20151231)>>>ed=BusinessDate(20201231)>>>BusinessRange(sd,ed,'1y',ed)[20151231,20161231,20171231,20181231,20191231]>>>BusinessSchedule(sd,ed,'1y',ed)[20151231,20161231,20171231,20181231,20191231,20201231]>>>BusinessSchedule(sd,ed,'1y',ed).first_stub_long()[20151231,20171231,20181231,20191231,20201231]
开发版本
最新的开发版本可以直接从github安装:
$ pip install --upgrade git+https://github.com/pbrisk/businessdate.git
贡献
Issues和Pull Requests总是受欢迎的。
许可证
根据apache软件许可证提供了代码和文档(请参见LICENSE)。