summaryrefslogtreecommitdiff
path: root/timestamp.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2021-03-05 08:12:55 +0100
committerAnthon van der Neut <anthon@mnt.org>2021-03-05 08:12:55 +0100
commit24e2600e50db8bbc211daf1405bf070efe9ddd83 (patch)
treee6c923c50ac4db4e878e3b22e5da8f9ccc7e360e /timestamp.py
parent1c31c7f46cfbc1f363c793f7bdf42c9f5fa239c6 (diff)
downloadruamel.yaml-24e2600e50db8bbc211daf1405bf070efe9ddd83.tar.gz
fix #365
Diffstat (limited to 'timestamp.py')
-rw-r--r--timestamp.py26
1 files changed, 26 insertions, 0 deletions
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