def serialize_trigger(alarm, container):
        if not alarm.trigger:
            raise ValueError("Alarm must have a trigger")

        if isinstance(alarm.trigger, timedelta):
            representation = timedelta_to_duration(alarm.trigger)
            container.append(ContentLine("TRIGGER", value=representation))
        else:
            container.append(
                ContentLine(
                    "TRIGGER",
                    params={"VALUE": ["DATE-TIME"]},
                    value=arrow_to_iso(alarm.trigger),
                ))
Beispiel #2
0
 def run_on_dataset(self, dataset):
     for test in dataset:
         expected = dataset[test]
         self.assertEqual(timedelta_to_duration(timedelta(*test)), expected)
 def serialize_duration(alarm, container):
     if alarm.duration:
         representation = timedelta_to_duration(alarm.duration)
         container.append(ContentLine("DURATION", value=representation))
Beispiel #4
0
 def run_on_dataset(self, dataset):
     for test in dataset:
         expected = dataset[test]
         self.assertEqual(timedelta_to_duration(timedelta(*test)), expected)
 def serialize_duration(todo: "Todo", container: Container):
     if todo._duration:
         representation = timedelta_to_duration(todo._duration)
         container.append(ContentLine("DURATION", value=representation))
Beispiel #6
0
 def serialize_duration(event, container):
     if event._duration and event.begin:
         representation = timedelta_to_duration(event._duration)
         container.append(ContentLine("DURATION", value=representation))