Move to the ics
library
This commit is contained in:
parent
37bc5948e2
commit
04baff10a6
16
main.py
16
main.py
|
@ -4,7 +4,7 @@ Generated by ChatGPT 3.5 (https://chatgpt.com/c/103d4f23-7c8f-484f-9598-d38187e9
|
|||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from icalendar import Calendar, Event
|
||||
from ics import Calendar, Event
|
||||
|
||||
|
||||
def mothering_sunday(year: int) -> datetime: # pylint: disable=too-many-locals
|
||||
|
@ -45,8 +45,6 @@ def generate_ical() -> None:
|
|||
Generate an ICAL file for Mothering Sunday (UK)
|
||||
"""
|
||||
cal = Calendar()
|
||||
cal.add("prodid", "-//Mothering Sunday Calendar//wallace.sh//")
|
||||
cal.add("version", "2.0")
|
||||
|
||||
for year in range(datetime.now().year, datetime.now().year + 10):
|
||||
date = mothering_sunday(year)
|
||||
|
@ -54,13 +52,13 @@ def generate_ical() -> None:
|
|||
if date.weekday() != 6: # 6 corresponds to Sunday
|
||||
date += timedelta(days=6 - date.weekday())
|
||||
event = Event()
|
||||
event.add("summary", "Mothering Sunday")
|
||||
event.add("dtstart", date)
|
||||
event.add("dtend", date + timedelta(days=1))
|
||||
cal.add_component(event)
|
||||
event.name = "Mothering Sunday"
|
||||
event.begin = date
|
||||
event.make_all_day()
|
||||
cal.events.add(event)
|
||||
|
||||
with open("mothering_sunday.ics", "wb") as f:
|
||||
f.write(cal.to_ical())
|
||||
with open("mothering_sunday.ics", "w", encoding="utf-8") as f:
|
||||
f.write(cal.serialize())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue