[ANN] python-dateutil 0.1

Robin Becker robin at jessikat.fsnet.co.uk
Thu Oct 9 14:22:15 EDT 2003


In article <mailman.1065706157.8588.python-list at python.org>, Gustavo
Niemeyer <niemeyer at conectiva.com> writes
>> >What is it?
>> >-----------
>> >The dateutil module provides powerful extensions to the standard
>> >datetime module, available in Python 2.3+.
>> >
>> .... is there support for business dates ie number of business days
>> between two dates etc?
>
>It will be hard to find something you can't do. :-)
>
>How may work days until the end of the month?
>
>   >>> from dateutil.rrule import *
>   >>> from datetime import *
>   >>> now = datetime.now()
>   >>> len(list(rrule(FREQ_DAILY,byweekday=(MO,TU,WE,TH,FR),
>                      dtstart=now,until=now.replace(day=31))))
>   16
>
>Hummm.. interesting enough, this result is not right. Today should
>also be counted in this case. There's a small bug related to
>micrseconds handling in the module: since the recurrence is compared
>against a date without microseconds, the recurrence is not greater
>than the dtstart passed. I haven't got this because all 415 testcases
>were using datetime instances without microseconds. Well, we
>have 417 now.. ;-)
>
>Here is the right result, with the fix:
>
>   >>> len(list(rrule(FREQ_DAILY,byweekday=(MO,TU,WE,TH,FR),
>                      dtstart=now,until=now.replace(day=31))))
>   17
>
>Thanks!
>
wow great. Do we have a to find the next bank holiday microsecond :).

With this functionality it'll make calculating those bond prices even
more interesting.
-- 
Robin Becker




More information about the Python-list mailing list