From 24e2600e50db8bbc211daf1405bf070efe9ddd83 Mon Sep 17 00:00:00 2001 From: Anthon van der Neut Date: Fri, 5 Mar 2021 08:12:55 +0100 Subject: fix #365 --- timestamp.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/timestamp.py b/timestamp.py index 374e4c0..e44db44 100644 --- a/timestamp.py +++ b/timestamp.py @@ -1,3 +1,4 @@ + # coding: utf-8 from __future__ import print_function, absolute_import, division, unicode_literals @@ -26,3 +27,28 @@ class TimeStamp(datetime.datetime): ts = TimeStamp(self.year, self.month, self.day, self.hour, self.minute, self.second) ts._yaml = copy.deepcopy(self._yaml) return ts + + def replace(self, year=None, month=None, day=None, hour=None, + minute=None, second=None, microsecond=None, tzinfo=True, + fold=None): + if year is None: + year = self.year + if month is None: + month = self.month + if day is None: + day = self.day + if hour is None: + hour = self.hour + if minute is None: + minute = self.minute + if second is None: + second = self.second + if microsecond is None: + microsecond = self.microsecond + if tzinfo is True: + tzinfo = self.tzinfo + if fold is None: + fold = self.fold + ts = type(self)(year, month, day, hour, minute, second, microsecond, tzinfo, fold=fold) + ts._yaml = copy.deepcopy(self._yaml) + return ts -- cgit v1.2.1