diff --git a/2020.ics b/2020.ics index a5b8b0d..0659c86 100644 --- a/2020.ics +++ b/2020.ics @@ -35,13 +35,6 @@ DTSTAMP;VALUE=DATE:20200124 UID:2020-01-24/2020-02-03/NateScarlet/holiday-cn END:VEVENT BEGIN:VEVENT -SUMMARY:上班(补春节假期) -DTSTART;VALUE=DATE:20200203 -DTEND;VALUE=DATE:20200204 -DTSTAMP;VALUE=DATE:20200203 -UID:2020-02-03/2020-02-04/NateScarlet/holiday-cn -END:VEVENT -BEGIN:VEVENT SUMMARY:清明节假期 DTSTART;VALUE=DATE:20200404 DTEND;VALUE=DATE:20200407 diff --git a/2020.json b/2020.json index c9a0436..9deeec8 100644 --- a/2020.json +++ b/2020.json @@ -67,11 +67,6 @@ "date": "2020-02-02", "isOffDay": true }, - { - "name": "春节", - "date": "2020-02-03", - "isOffDay": false - }, { "name": "清明节", "date": "2020-04-04", diff --git a/fetch_holidays.py b/fetch_holidays.py index 7090a92..c0cc8e2 100755 --- a/fetch_holidays.py +++ b/fetch_holidays.py @@ -42,7 +42,24 @@ PRE_PARSED_PAPERS = { "date": date(2015, 9, 6), "isOffDay": False, }, - ] + ], + "http://www.gov.cn/zhengce/content/2020-01/27/content_5472352.htm": [ + { + "name": "春节", + "date": date(2020, 1, 31), + "isOffDay": True, + }, + { + "name": "春节", + "date": date(2020, 2, 1), + "isOffDay": True, + }, + { + "name": "春节", + "date": date(2020, 2, 2), + "isOffDay": True, + }, + ], } @@ -236,14 +253,6 @@ class DescriptionParser: class SentenceParser: """Parser for holiday shift description sentence.""" - special_cases = { - "延长2020年春节假期至2月2日(农历正月初九": [ - {"date": date(2020, 1, 31), "isOffDay": True}, - {"date": date(2020, 2, 1), "isOffDay": True}, - {"date": date(2020, 2, 2), "isOffDay": True}, - ], - } - def __init__(self, parent: DescriptionParser, sentence): self.parent = parent self.sentence = sentence @@ -343,15 +352,10 @@ class SentenceParser: for i in self.extract_dates(match.group(2)): yield {"date": i, "isOffDay": True} - def _parse_special(self): - for i in self.special_cases.get(self.sentence, []): - yield i - parsing_methods = [ _parse_rest_1, _parse_work_1, _parse_shift_1, - _parse_special, ] diff --git a/holiday-cn.ics b/holiday-cn.ics index f3fdfbe..0b3454c 100644 --- a/holiday-cn.ics +++ b/holiday-cn.ics @@ -210,13 +210,6 @@ DTSTAMP;VALUE=DATE:20200124 UID:2020-01-24/2020-02-03/NateScarlet/holiday-cn END:VEVENT BEGIN:VEVENT -SUMMARY:上班(补春节假期) -DTSTART;VALUE=DATE:20200203 -DTEND;VALUE=DATE:20200204 -DTSTAMP;VALUE=DATE:20200203 -UID:2020-02-03/2020-02-04/NateScarlet/holiday-cn -END:VEVENT -BEGIN:VEVENT SUMMARY:清明节假期 DTSTART;VALUE=DATE:20200404 DTEND;VALUE=DATE:20200407 diff --git a/tests/description_parsing_cases.json b/tests/description_parsing_cases.json index d651a8e..5f88a12 100644 --- a/tests/description_parsing_cases.json +++ b/tests/description_parsing_cases.json @@ -1,14 +1,4 @@ [ - { - "year": 2020, - "description": "延长2020年春节假期至2月2日(农历正月初九,星期日),2月3日(星期一)起正常上班。", - "expected": [ - { "date": "2020-01-31", "isOffDay": true }, - { "date": "2020-02-01", "isOffDay": true }, - { "date": "2020-02-02", "isOffDay": true }, - { "date": "2020-02-03", "isOffDay": false } - ] - }, { "year": 2019, "description": "2018年12月30日至2019年1月1日放假调休,共3天。2018年12月29日(星期六)上班。",