From 90ddef2d8ced340cd7cb77f6907c7889cd242936 Mon Sep 17 00:00:00 2001 From: rbowen Date: Fri, 12 Mar 2021 09:11:55 -0500 Subject: [PATCH] Adds second- and fourth- week recurring meetings Change-Id: I072e0018f24ced12b0b4557c8cc2db6b6a8d0ff5 --- README.rst | 16 ++--- yaml2ical/meeting.py | 10 +++ yaml2ical/recurrence.py | 10 +++ yaml2ical/tests/sample_data.py | 112 +++++++++++++++++++++++++++++ yaml2ical/tests/test_recurrence.py | 7 ++ 5 files changed, 143 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index e0f59ab..29796c4 100644 --- a/README.rst +++ b/README.rst @@ -163,21 +163,13 @@ yaml2ical supports a number of possible frequency options: * ``quadweekly-week-2``, ``quadweekly-alternate``: Occurs when ``ISOweek % 4 == 2`` * ``quadweekly-week-3``: Occurs when ``ISOweek % 4 == 3`` -* Event occurs in the first week of a month: +* Event occurs in a particular week of a month: * ``first-monday``: On the first Monday of the month. - * ``first-tuesday``: On the first Tuesday of the month. - * ``first-wednesday``: On the first Wednesday of the month. - * ``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. + * ``second-tuesday``: On the second 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. + * ``fourth-thursday``: On the fourth Thursday of the month. + * etc * 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 c2a37f2..db5a8e2 100644 --- a/yaml2ical/meeting.py +++ b/yaml2ical/meeting.py @@ -153,11 +153,21 @@ class Schedule(object): 'first-wednesday': set([0, 1, 2, 3]), 'first-thursday': set([0, 1, 2, 3]), 'first-friday': set([0, 1, 2, 3]), + 'second-monday': set([0, 1, 2, 3]), + 'second-tuesday': set([0, 1, 2, 3]), + 'second-wednesday': set([0, 1, 2, 3]), + 'second-thursday': set([0, 1, 2, 3]), + 'second-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]), + 'fourth-monday': set([0, 1, 2, 3]), + 'fourth-tuesday': set([0, 1, 2, 3]), + 'fourth-wednesday': set([0, 1, 2, 3]), + 'fourth-thursday': set([0, 1, 2, 3]), + 'fourth-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 98986bc..49a08d9 100644 --- a/yaml2ical/recurrence.py +++ b/yaml2ical/recurrence.py @@ -254,9 +254,19 @@ supported_recurrences = { 'first-wednesday': MonthlyRecurrence(week=1, day='Wednesday'), 'first-thursday': MonthlyRecurrence(week=1, day='Thursday'), 'first-friday': MonthlyRecurrence(week=1, day='Friday'), + 'second-monday': MonthlyRecurrence(week=2, day='Monday'), + 'second-tuesday': MonthlyRecurrence(week=2, day='Tuesday'), + 'second-wednesday': MonthlyRecurrence(week=2, day='Wednesday'), + 'second-thursday': MonthlyRecurrence(week=2, day='Thursday'), + 'second-friday': MonthlyRecurrence(week=2, 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'), + 'fourth-monday': MonthlyRecurrence(week=4, day='Monday'), + 'fourth-tuesday': MonthlyRecurrence(week=4, day='Tuesday'), + 'fourth-wednesday': MonthlyRecurrence(week=4, day='Wednesday'), + 'fourth-thursday': MonthlyRecurrence(week=4, day='Thursday'), + 'fourth-friday': MonthlyRecurrence(week=4, day='Friday'), } diff --git a/yaml2ical/tests/sample_data.py b/yaml2ical/tests/sample_data.py index 9cecf75..1885031 100644 --- a/yaml2ical/tests/sample_data.py +++ b/yaml2ical/tests/sample_data.py @@ -447,6 +447,48 @@ description: > Example Monthly meeting """ +SECOND_WEDNESDAY_MEETING = """ +project: CentOS Cloud SIG +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Wednesday + irc: centos-meeting + frequency: second-wednesday +chair: Jane Deer +description: > + Example Monthly meeting +""" + +SECOND_THURSDAY_MEETING = """ +project: CentOS Storage SIG +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Thursday + irc: centos-meeting + frequency: second-thursday +chair: Jane Deer +description: > + Example Monthly meeting +""" + +SECOND_FRIDAY_MEETING = """ +project: CentOS Hyperscale SIG +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Friday + irc: centos-meeting + frequency: second-friday +chair: Jane Deer +description: > + Example Monthly meeting +""" + THIRD_MONDAY_MEETING = """ project: OpenStack Random Meeting agenda_url: http://agenda.com/ @@ -516,3 +558,73 @@ chair: John Doe description: > Example Monthly meeting """ + +FOURTH_MONDAY_MEETING = """ +project: CentOS SIG Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Monday + irc: centos-meeting + frequency: fourth-monday +chair: Jane Deer +description: > + Example Monthly meeting +""" + +FOURTH_TUESDAY_MEETING = """ +project: CentOS SIG Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Tuesday + irc: centos-meeting + frequency: fourth-tuesday +chair: Jane Deer +description: > + Example Monthly meeting +""" + +FOURTH_WEDNESDAY_MEETING = """ +project: CentOS SIG Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Wednesday + irc: centos-meeting + frequency: fourth-wednesday +chair: Jane Deer +description: > + Example Monthly meeting +""" + +FOURTH_THURSDAY_MEETING = """ +project: CentOS SIG Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Thursday + irc: centos-meeting + frequency: fourth-thursday +chair: Jane Deer +description: > + Example Monthly meeting +""" + +FOURTH_FRIDAY_MEETING = """ +project: CentOS SIG Meeting +agenda_url: http://agenda.com/ +project_url: http://project.com +schedule: + - time: '2200' + day: Friday + irc: centos-meeting + frequency: fourth-friday +chair: Jane Deer +description: > + Example Monthly meeting +""" diff --git a/yaml2ical/tests/test_recurrence.py b/yaml2ical/tests/test_recurrence.py index 9f7006d..c8ee49f 100644 --- a/yaml2ical/tests/test_recurrence.py +++ b/yaml2ical/tests/test_recurrence.py @@ -105,6 +105,13 @@ class RecurrenceTestCase(unittest.TestCase): self.next_meeting(rec), ) + def test_monthly_fourth_week(self): + rec = recurrence.MonthlyRecurrence(week=4, day='Tuesday') + self.assertEqual( + datetime.datetime(2014, 11, 26, 2, 47, 28, 832666), + self.next_meeting(rec), + ) + def test_monthly_invalid_week(self): rec = recurrence.MonthlyRecurrence(week=6, day='Wednesday') self.assertRaises(