From 2ca52c339df509977044f60109dcf1966a791ffc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Mon, 18 Jan 2021 10:33:15 +0100 Subject: [PATCH 1/2] Add direct way of retrieving Headline ID . --- org_rw/org_rw.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index a4a98b7..37be9c8 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -271,6 +271,10 @@ class Headline: return "".join(contents).rstrip() + @property + def id(self): + return self.get_property("ID") + @property def clock(self): times = [] From 88e709f7db12865825ce9c160cd7ccd026e40965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Mon, 18 Jan 2021 10:33:34 +0100 Subject: [PATCH 2/2] Fix OrgTime and TimeRange duraction getters. --- org_rw/org_rw.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index 37be9c8..d0a7d80 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -587,13 +587,11 @@ class TimeRange: @property def start(self) -> datetime: - st = self.start_time - return datetime(st.year, st.month, st.day, st.hour or 0, st.minute or 0) + return self.start_time.time.to_datetime() @property def end(self) -> datetime: - et = self.end_time - return datetime(et.year, et.month, et.day, et.hour or 0, et.minute or 0) + return self.end_time.time.to_datetime() def parse_time(value: str) -> Union[None, TimeRange, OrgTime]: @@ -624,6 +622,13 @@ class OrgTime: self.time = ts self.end_time = end_time + @property + def duration(self): + if self.end_time is None: + return timedelta() # No duration + else: + return self.end_time.to_datetime() - self.time.to_datetime() + def to_raw(self): return timestamp_to_string(self.time, self.end_time)