def serialize_trigger(alarm, container): if not alarm.trigger: raise ValueError("Alarm must have a trigger") if isinstance(alarm.trigger, timedelta): representation = serialize_duration(alarm.trigger) container.append(ContentLine("TRIGGER", value=representation)) else: cl = serialize_datetime_to_contentline("TRIGGER", alarm.trigger) cl.params["VALUE"] = ["DATE-TIME"] container.append(cl)
def serialize_start(event: "Event", container: "Container"): if event.begin: if not event.all_day: container.append( serialize_datetime_to_contentline("DTSTART", event.begin)) else: container.append( ContentLine( "DTSTART", params={"VALUE": ["DATE"]}, value=serialize_date(event.begin), ))
def serialize_end(event: "Event", container: "Container"): if event.end_representation == "end": end = event.end assert end is not None if not event.all_day: container.append( serialize_datetime_to_contentline("DTEND", end)) else: container.append( ContentLine( "DTSTART", params={"VALUE": ["DATE"]}, value=serialize_date(end), ))
def serialize_created(event: "Event", container: "Container"): if event.created: container.append( serialize_datetime_to_contentline("CREATED", event.created))
def serialize_last_modified(event: "Event", container: "Container"): if event.last_modified: container.append( serialize_datetime_to_contentline("LAST-MODIFIED", event.last_modified))
def serialize_due(todo: "Todo", container: Container): if todo.due_representation == "end": due = todo.due assert due is not None container.append(serialize_datetime_to_contentline("DUE", due))
def serialize_dtstamp(event: "Event", container: "Container"): container.append( serialize_datetime_to_contentline("DTSTAMP", event.dtstamp))
def serialize_start(todo: "Todo", container: Container): if todo.begin: container.append( serialize_datetime_to_contentline("DTSTART", todo.begin))
def serialize_completed(todo: "Todo", container: Container): if todo.completed: container.append( serialize_datetime_to_contentline("COMPLETED", todo.completed))
def serialize_last_modified(todo: "Todo", container: "Container"): if todo.last_modified: container.append( serialize_datetime_to_contentline("LAST-MODIFIED", todo.last_modified))
def serialize_created(todo: "Todo", container: "Container"): if todo.created: container.append( serialize_datetime_to_contentline("CREATED", todo.created))
def serialize_dtstamp(todo: "Todo", container: "Container"): container.append( serialize_datetime_to_contentline("DTSTAMP", todo.dtstamp))