diff --git a/README.rst b/README.rst index 76cac58..e0f59ab 100644 --- a/README.rst +++ b/README.rst @@ -171,6 +171,14 @@ yaml2ical supports a number of possible frequency options: * ``first-thursday``: On the first Thursday of the month. * ``first-friday``: On the first Friday of the month. +* Event occurs in the third week of a month: + + * ``third-monday``: On the third Monday of the month. + * ``third-tuesday``: On the third Tuesday of the month. + * ``third-wednesday``: On the third Wednesday of the month. + * ``third-thursday``: On the third Thursday of the month. + * ``third-friday``: On the third Friday of the month. + * Event doesn't happen on a defined schedule but is used as a placeholder for html generation: diff --git a/yaml2ical/meeting.py b/yaml2ical/meeting.py index aa28629..c2a37f2 100644 --- a/yaml2ical/meeting.py +++ b/yaml2ical/meeting.py @@ -153,6 +153,11 @@ class Schedule(object): 'first-wednesday': set([0, 1, 2, 3]), 'first-thursday': set([0, 1, 2, 3]), 'first-friday': set([0, 1, 2, 3]), + 'third-monday': set([0, 1, 2, 3]), + 'third-tuesday': set([0, 1, 2, 3]), + 'third-wednesday': set([0, 1, 2, 3]), + 'third-thursday': set([0, 1, 2, 3]), + 'third-friday': set([0, 1, 2, 3]), } return len(week[self.freq].intersection(week[other.freq])) > 0 diff --git a/yaml2ical/recurrence.py b/yaml2ical/recurrence.py index e31186e..98986bc 100644 --- a/yaml2ical/recurrence.py +++ b/yaml2ical/recurrence.py @@ -254,4 +254,9 @@ supported_recurrences = { 'first-wednesday': MonthlyRecurrence(week=1, day='Wednesday'), 'first-thursday': MonthlyRecurrence(week=1, day='Thursday'), 'first-friday': MonthlyRecurrence(week=1, day='Friday'), + 'third-monday': MonthlyRecurrence(week=3, day='Monday'), + 'third-tuesday': MonthlyRecurrence(week=3, day='Tuesday'), + 'third-wednesday': MonthlyRecurrence(week=3, day='Wednesday'), + 'third-thursday': MonthlyRecurrence(week=3, day='Thursday'), + 'third-friday': MonthlyRecurrence(week=3, day='Friday'), } diff --git a/yaml2ical/tests/sample_data.py b/yaml2ical/tests/sample_data.py index dd1996e..9cecf75 100644 --- a/yaml2ical/tests/sample_data.py +++ b/yaml2ical/tests/sample_data.py @@ -446,3 +446,73 @@ chair: John Doe description: > Example Monthly meeting """ + +THIRD_MONDAY_MEETING = """ +project: OpenStack Random Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Monday + irc: openstack-meeting + frequency: third-monday +chair: John Doe +description: > + Example Monthly meeting +""" + +THIRD_TUESDAY_MEETING = """ +project: OpenStack Random Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Tuesday + irc: openstack-meeting + frequency: third-tuesday +chair: John Doe +description: > + Example Monthly meeting +""" + +THIRD_WEDNESDAY_MEETING = """ +project: OpenStack Random Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Wednesday + irc: openstack-meeting + frequency: third-wednesday +chair: John Doe +description: > + Example Monthly meeting +""" + +THIRD_THURSDAY_MEETING = """ +project: OpenStack Random Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Thursday + irc: openstack-meeting + frequency: third-thursday +chair: John Doe +description: > + Example Monthly meeting +""" + +THIRD_FRIDAY_MEETING = """ +project: OpenStack Random Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Friday + irc: openstack-meeting + frequency: third-friday +chair: John Doe +description: > + Example Monthly meeting +""" diff --git a/yaml2ical/tests/test_recurrence.py b/yaml2ical/tests/test_recurrence.py index 20259a6..9f7006d 100644 --- a/yaml2ical/tests/test_recurrence.py +++ b/yaml2ical/tests/test_recurrence.py @@ -98,6 +98,13 @@ class RecurrenceTestCase(unittest.TestCase): self.next_meeting(rec), ) + def test_monthly_third_week(self): + rec = recurrence.MonthlyRecurrence(week=3, day='Thursday') + self.assertEqual( + datetime.datetime(2014, 11, 19, 2, 47, 28, 832666), + self.next_meeting(rec), + ) + def test_monthly_invalid_week(self): rec = recurrence.MonthlyRecurrence(week=6, day='Wednesday') self.assertRaises(