Skip to content

Commit

Permalink
fix: alerts are not properly implemented (fix #39) (#41)
Browse files Browse the repository at this point in the history
* fix: use icalendar.Alarm to properly create alerts

* rename icalendar's alert to alarm

* docs: update readme
  • Loading branch information
eoleedi committed Jul 17, 2024
1 parent 30014ff commit 20859de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ You are recommended to import the ics file into a separate calendar (take google
icalendar==5.0.12

# Limitations
Currently, TimeTree data can only be downloaded manually through a web browser.
1. Currently, TimeTree data can only be downloaded manually through a web browser.
2. Alarms(Alerts) can't be imported to Google Calendar through iCal format due to Google's bug.

# Support
If you think it's helpful, kindly support me!
Expand Down
18 changes: 9 additions & 9 deletions timetree_exporter/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from datetime import datetime, timedelta
from zoneinfo import ZoneInfo
from icalendar import Event, vRecur, vDate, vDatetime, vGeo
from icalendar import Event, vRecur, vDate, vDatetime, vGeo, Alarm
from icalendar.prop import vDDDLists
from icalendar.parser import Contentline
from timetree_exporter.event import (
Expand Down Expand Up @@ -126,16 +126,16 @@ def dtend(self):
return self.get_datetime(is_start_time=False)

@property
def alerts(self):
"""Return the alerts of the event."""
alerts = []
def alarms(self):
"""Return the alarms of the event."""
alarms = []
for alert in self.time_tree_event.alerts:
alarm = Event()
alarm = Alarm()
alarm.add("action", "DISPLAY")
alarm.add("description", "Reminder")
alarm.add("trigger", timedelta(minutes=-alert))
alerts.append(alarm)
return alerts
alarms.append(alarm)
return alarms

def add_recurrences(self, event):
"""Add recurrences to iCal event"""
Expand Down Expand Up @@ -205,8 +205,8 @@ def to_ical(self) -> Event:
if self.related_to:
event.add("related-to", self.related_to)

for alert in self.alerts:
event.add_component(alert)
for alarm in self.alarms:
event.add_component(alarm)

self.add_recurrences(event)

Expand Down

0 comments on commit 20859de

Please sign in to comment.