tags:

views:

56

answers:

2

I'd like to find a library or command that given input like "every third tuesday" will provide a list of dates such as (2010-06-15, 2010-07-20, 2010-08-17), etc.

Something that can be called from python, unix command line, or a web api would be perfect.

+1  A: 

Try the calendar module. Here is a good writeup -- it is part of what you are asking for: http://www.doughellmann.com/PyMOTW/calendar/index.html

scrible
+4  A: 

There's always dateutil.
Example below is based on ~unutbu's excellent answer to this very similar SO question:

>>> from datetime import date
>>> from dateutil import rrule, relativedelta
>>> every_third_tuesday = rrule.rrule(rrule.MONTHLY, 
                                      byweekday=relativedelta.TU(3), 
                                      dtstart=date.today(), 
                                      count=3)
>>> for tt in every_third_tuesday:
...   print tt.date()
... 
2010-07-20
2010-08-17
2010-09-21
Adam Bernier
Python is so cool! :)
st0le