|
|
|
@ -13,13 +13,13 @@ else: |
|
|
|
flags = argparse.ArgumentParser(parents=[tools.argparser]).parse_args() |
|
|
|
APPLICATION_NAME = 'Google Calendar API Python' |
|
|
|
|
|
|
|
SUN = 0 |
|
|
|
MON = 1 |
|
|
|
TUE = 2 |
|
|
|
WED = 3 |
|
|
|
THU = 4 |
|
|
|
FRI = 5 |
|
|
|
SAT = 6 |
|
|
|
SUN = 6 |
|
|
|
MON = 0 |
|
|
|
TUE = 1 |
|
|
|
WED = 2 |
|
|
|
THU = 3 |
|
|
|
FRI = 4 |
|
|
|
SAT = 5 |
|
|
|
|
|
|
|
|
|
|
|
def to_dateTime(datetime: datetime.datetime): |
|
|
|
@ -147,6 +147,7 @@ class Event: |
|
|
|
self.name = name |
|
|
|
self.description = description |
|
|
|
self.location = location |
|
|
|
self.recurrence = recurrence |
|
|
|
self.id = id |
|
|
|
if reminders is None: |
|
|
|
self.reminders = {'useDefault': True} |
|
|
|
@ -169,13 +170,13 @@ class Event: |
|
|
|
}) |
|
|
|
|
|
|
|
def add_weekly_recurrence(self, until: datetime.datetime, *days): |
|
|
|
if not until.tzinfo: |
|
|
|
until = until.astimezone() |
|
|
|
ret = rrule.rrule(freq=rrule.WEEKLY, dtstart=self.start, |
|
|
|
wkst=SUN, until=until, byweekday=days) |
|
|
|
ret_str = str(ret).split('\n')[-1] |
|
|
|
ret_str = re.sub(r'(UNTIL=[^;]+)', r'\1Z', ret_str) |
|
|
|
try: |
|
|
|
self.recurrence |
|
|
|
except AttributeError: |
|
|
|
if self.recurrence is None: |
|
|
|
self.recurrence = [] |
|
|
|
self.recurrence.append(ret_str) |
|
|
|
|
|
|
|
@ -268,4 +269,6 @@ if __name__ == "__main__": |
|
|
|
path, 'client_secret.json', path), path) |
|
|
|
cal_id = 'raphael.roberts48@gmail.com' |
|
|
|
e2 = Event.from_id(my_api, cal_id, 'qmrsd88ma8ko67ri98d8pbhd7s') |
|
|
|
until = datetime.datetime.today() + datetime.timedelta(days=20) |
|
|
|
e2.add_weekly_recurrence(until, MON, TUE) |
|
|
|
# e2.upload(my_api, cal_id) |