1

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.

Mark Harrison
  • 283,715
  • 120
  • 322
  • 449

2 Answers2

7

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
Community
  • 1
  • 1
mechanical_meat
  • 155,494
  • 24
  • 217
  • 209
1

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

Arkady
  • 13,115
  • 7
  • 38
  • 46