From b28ec3e9b03f1595eaf4bb82ef1f01c3c4d1c2b6 Mon Sep 17 00:00:00 2001 From: Rob Golding Date: Wed, 17 Apr 2013 20:52:36 +0100 Subject: [PATCH] Add serialize/deserialize methods for annotations --- tasklib/task.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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()) -- 2.39.5