Blackskirt (GitHub) is a Python library for finding out dates like the date of nth Wednesday in April, 1999.
For example, this Thanksgiving is going to be on 2014-11-27:
>>> from blackskirt import ( ... WEEKDAY_MON, WEEKDAY_TUE, WEEKDAY_WED, ... WEEKDAY_THU, WEEKDAY_FRI, WEEKDAY_SAT, ... WEEKDAY_SUN,) >>> from blackskirt.ops import ( ... mondayise, next_weekday, prev_weekday, ... nearest_weekday, nth_weekday, last_weekday, ... next_date, prev_date, nearest_date,) >>> nth_weekday(year=2014, ... month=11, ... n=4, ... weekday=WEEKDAY_THU) '2014-11-27'
The query is asking the fourth Friday in November, 2014. And the Black Friday and Cyber Monday will be on 2014-11-28 and 2014-12-01, respectively:
>>> next_weekday(year=2014, ... month=11, ... day=27, ... weekday=WEEKDAY_FRI) '2014-11-28' >>> next_weekday(year=2014, ... month=11, ... day=27, ... weekday=WEEKDAY_MON) '2014-12-01'
It has other functions such as mondayise, nearest_weekday, last_weekday, prev_date, and next_date for other querying. It only answers with one format, YYYY-MM-DD, simple and not ambiguous at all.
It’s written by James Nah under the LGPLv3, currently version 0.1.1 (2014-04-15), it runs on both Python 2 and 3.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.