THIS IS PRERELEASE SOFTWARE - CREATE ISSES ON GITHUB!!!
dateroll makes working with π
dates less painful.
$ pip install dateroll
$ python
>>> from dateroll import ddh
>>> ddh("t+2bd")
ddh (date-duration-helper) is your πͺ magic wand for π
dates.
| category | input | output |
|---|---|---|
Date |
ddh('t') (t is today)ddh('5/5/5')ddh('2024-02-15') |
Date(2024,2,19)Date(2005,5,5)Date(2024,2,15) |
Duration |
ddh('1d')ddh('1m')ddh('1y')ddh('1d|NY')ddh('1d|NY/MF')ddh('1d|NYuLN') |
Duration(d=1)Duration(m=1)Duration(y=1)Duration(d=1,cal='NY')Duration(d=1,cal='NY', roll='MF')Duration(d=1, cal={'NY', 'LN'}, roll='MF) |
Schedule |
ddh('t, 6m, 20')ddh('t, t+5y ,6m') |
Schedule(start='2/19/24', step='6m', n=20)Schedule(start='2/20/24', stop='2/20/29, step='6m') |
from dateroll import Date, Duration, Schedule
in dateroll |
Example | python native equivalent |
|---|---|---|
Date |
ddd('7/2/84')A date |
datetime.datedatetime.datetime |
Duration |
ddh('1y'), or ddh('1m')A Duration |
datetime.timedeltadateutil.relativedelta.relativedelta |
Schedule |
ddh('1/15/2024,1m,60)Payment dates |
dateutil.rrule.rrule |
| left side | operation | right side | output |
|---|---|---|---|
Date |
Duration |
Date |
|
Duration |
Duration |
Duration |
>>> d = ddh('2/16/22') # a friday before presidents day
>>> d + '1bd|NY'# see calendars section later
Date(2022,2,20)
>>> ddh(')
| left side | operation | right side | output |
|---|---|---|---|
Date |
Date |
Duration |
|
Date |
Duration |
Date |
>>> t1 = ddh('1/5/24')
>>> t2 = ddh('2/6/24')
>>> t2-t1
Duration(start='1/5/24',stop='2/5/24')
| method | description |
|---|---|
Duration.approx |
approximate largest duration |
Duration.exact |
Duration of days only |
Duration.ncd |
int of calendar days |
Duration.nbd |
int of working days (if cal provided on t1) |
>>> (t2-t1).approx
>>> (t2-t1).exact
>>> (t2-t1).ncd # WE cal is explicit
>>> (t2-t1).ncd('NY')
>>> (t2-t1).nbd
Much more in the reference docs.
Happy rolling!