From 608cefe02b29fbffe2f7a18124447475055962f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADnez=20Portela?= Date: Sun, 7 Feb 2021 23:59:35 +0100 Subject: [PATCH] Add support for timedelta operation on Timestamp. --- org_rw/org_rw.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/org_rw/org_rw.py b/org_rw/org_rw.py index d0a7d80..77a6eb3 100644 --- a/org_rw/org_rw.py +++ b/org_rw/org_rw.py @@ -474,6 +474,23 @@ class Timestamp: else: return datetime(self.year, self.month, self.day, 0, 0) + def __add__(self, delta: timedelta): + as_dt = self.to_datetime() + to_dt = as_dt + delta + + return Timestamp( + self.active, + year=to_dt.year, + month=to_dt.month, + day=to_dt.day, + dow=None, + hour=to_dt.hour if self.hour is not None or to_dt.hour != 0 else None, + minute=to_dt.minute + if self.minute is not None or to_dt.minute != 0 + else None, + repetition=self.repetition, + ) + def __eq__(self, other): if not isinstance(other, Timestamp): return False