def add_event(event_name, date, start_time, end_time): global calendar event = Event() start = ContentLine.parse("DTSTART;TZID=Asia/Shanghai:{0}T{1}00".format( date, start_time)) end = ContentLine.parse("DTSTART;TZID=Asia/Shanghai:{0}T{1}00".format( date, end_time)) start_arr = iso_to_arrow(start) end_arr = iso_to_arrow(end) event.name = event_name event.begin = start_arr event.end = end_arr calendar.events.add(event)
def parse_due(todo: "Todo", line: ContentLine): if line: # TODO: DRY [1] if todo._duration: raise ValueError("A todo can't have both DUE and DURATION") # get the dict of vtimezones passed to the classmethod tz_dict = todo._classmethod_kwargs["tz"] todo._due_time = iso_to_arrow(line, tz_dict)
def parse_dtend(event, line): if line: # TODO: DRY [1] if event._duration: raise ValueError("An event can't have both DTEND and DURATION") # get the dict of vtimezones passed to the classmethod tz_dict = event._classmethod_kwargs["tz"] event._end_time = iso_to_arrow(line, tz_dict)
def parse_trigger(alarm, line): if line.params.get("VALUE", [""])[0] == "DATE-TIME": alarm.trigger = iso_to_arrow(line) elif line.params.get("VALUE", ["DURATION"])[0] == "DURATION": alarm.trigger = parse_duration(line.value) else: warnings.warn( "ics.py encountered a TRIGGER of unknown type '%s'. It has been ignored." % line.params["VALUE"][0])
def test_none(self): self.assertIs(None, iso_to_arrow(None))
def parse_dtstart(todo: "Todo", line: ContentLine): if line: # get the dict of vtimezones passed to the classmethod tz_dict = todo._classmethod_kwargs["tz"] todo.begin = iso_to_arrow(line, tz_dict)
def test_timezone_not_dropped(self): line = ContentLine.parse("DTSTART;TZID=Europe/Berlin:20151104T190000") arrow = iso_to_arrow(line) self.assertIn("Europe/Berlin", str(arrow.tzinfo))
def parse_dtstamp(event, line): if line: # get the dict of vtimezones passed to the classmethod tz_dict = event._classmethod_kwargs["tz"] event.created = iso_to_arrow(line, tz_dict)
def parse_dtstart(event, line): if line: # get the dict of vtimezones passed to the classmethod tz_dict = event._classmethod_kwargs["tz"] event.begin = iso_to_arrow(line, tz_dict) event._begin_precision = iso_precision(line.value)
def parse_last_modified(event, line): if line: tz_dict = event._classmethod_kwargs["tz"] event.last_modified = iso_to_arrow(line, tz_dict)