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
  • 297,451
  • 125
  • 333
  • 465

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
  • 163,903
  • 24
  • 228
  • 223
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
  • 14,305
  • 8
  • 42
  • 46