Mercurial > code > home > repos > gcalendarwatch
changeset 35:6d602c53eb33
fix bhs monday starts
author | drewp@bigasterisk.com |
---|---|
date | Tue, 22 Aug 2023 12:47:28 -0700 |
parents | 281e4b12dd37 |
children | cb990883e52f |
files | create_school_cals.py create_school_cals_2.py |
diffstat | 2 files changed, 36 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/create_school_cals.py Wed Aug 16 18:14:22 2023 -0700 +++ b/create_school_cals.py Tue Aug 22 12:47:28 2023 -0700 @@ -43,7 +43,7 @@ for calId, school, grade, startHM in [ (calIdForPerson['twins'], 'john muir', 'K', (9, 10)), (calIdForPerson['asher'], 'john muir', '2', (9, 0)), - (calIdForPerson['ari'], 'BHS', '9', (8, 30)), + (calIdForPerson['ari'], 'BHS', '9th', (8, 30)), ]: if busdHoliday(s): continue @@ -58,15 +58,17 @@ endHM = (14, 15) elif grade == '2': endHM = (14, 15) if s.weekday() == 2 else (15, 10) - elif grade == '9': + elif grade == '9th': endHM = (14, 50) if s.weekday() == 2 else (15, 30) + if s.weekday() == 0: + startHM = (10, 0) s = s.replace(hour=startHM[0], minute=startHM[1]) e = s.replace(hour=endHM[0], minute=endHM[1]) # schema: https://developers.google.com/calendar/api/v3/reference/events#resource-representations event = { 'summary': summary, - 'description': 'auto-gen v1', + 'description': 'auto-gen v2', 'start': { 'dateTime': s.isoformat() },
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/create_school_cals_2.py Tue Aug 22 12:47:28 2023 -0700 @@ -0,0 +1,31 @@ +import datetime +import json +from pprint import pprint + +import tzlocal + +from calendar_connection import getCalendarService + +calIdForPerson = json.load(open('gcalendarwatch.conf'))['calId'] + +service = getCalendarService() + + +def find(calId, s: datetime.datetime, e: datetime.datetime, summary: str): + res = service.events().list( + calendarId=calId, + timeMin=s.isoformat(), + timeMax=e.isoformat(), + q=summary, + maxResults=2500, + ).execute() + for item in res['items']: + if item['summary'] != summary: + continue + yield item['id'] + + +s = datetime.datetime(2023, 8, 1, tzinfo=tzlocal.get_localzone()) +e = datetime.datetime(2024, 7, 1, tzinfo=tzlocal.get_localzone()) +for id in find(calIdForPerson['ari'], s=s, e=e, summary="BHS 9"): + service.events().delete(calendarId=calIdForPerson['ari'], eventId=id).execute()