From fdc475cb1904e13dad9855fa504f6551ca8ef9f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sat, 10 Apr 2021 11:13:30 +0200 Subject: [PATCH] Add comparison operations to Timestamp. --- org_rw/org_rw.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index b2b5832..413c7c7 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -568,6 +568,16 @@ class Timestamp: and (self.repetition == other.repetition) ) + def __lt__(self, other): + if not isinstance(other, Timestamp): + return False + return self.to_datetime() < other.to_datetime() + + def __gt__(self, other): + if not isinstance(other, Timestamp): + return False + return self.to_datetime() > other.to_datetime() + def __repr__(self): return timestamp_to_string(self)