From: Rob Golding Date: Wed, 17 Apr 2013 19:52:36 +0000 (+0100) Subject: Add serialize/deserialize methods for annotations X-Git-Url: https://git.madduck.net/etc/taskwarrior.git/commitdiff_plain/b28ec3e9b03f1595eaf4bb82ef1f01c3c4d1c2b6?ds=inline;hp=57c5057d9885ce0020fca03b83d1c75f6143fdc3 Add serialize/deserialize methods for annotations --- diff --git a/tasklib/task.py b/tasklib/task.py index 85ba042..80f08e9 100644 --- a/tasklib/task.py +++ b/tasklib/task.py @@ -52,6 +52,19 @@ class Task(object): return None return datetime.datetime.strptime(date_str, DATE_FORMAT) + def serialize_annotations(self, annotations): + ann_list = list(annotations) + for ann in ann_list: + ann['entry'] = ann['entry'].strftime(DATE_FORMAT) + return ann_list + + def deserialize_annotations(self, annotations): + ann_list = list(annotations) + for ann in ann_list: + ann['entry'] = datetime.datetime.strptime( + ann['entry'], DATE_FORMAT) + return ann_list + def regenerate_uuid(self): self['uuid'] = str(uuid.uuid4())