--- a/borgend/dreamtime.py Mon Jan 29 14:32:27 2018 +0000 +++ b/borgend/dreamtime.py Wed Jan 31 00:06:54 2018 +0000 @@ -31,6 +31,9 @@ return max(0, time.monotonic()-dreamtime_difference()) class Time: + def __init__(self, when): + self._value=when + def realtime(self): raise NotImplementedError @@ -57,12 +60,22 @@ def after(cls, seconds): return cls(cls._now()+seconds) + @classmethod + def after_other(cls, other, seconds): + if isinstance(other, cls): + return cls(other._value+seconds) + else: + return cls.from_monotonic(other.monotonic()+seconds) + def datetime(self): return datetime.datetime.fromtimestamp(self.realtime()) def seconds_to(self): return self._value-self._now() + def isoformat(self): + return self.datetime().isoformat() + def __lt__(self, other): return self.monotonic() < other.monotonic() @@ -79,9 +92,6 @@ return self.monotonic() == other.realtime() class RealTime(Time): - def __init__(self, when): - self._value=when - def realtime(self): return self._value @@ -93,9 +103,6 @@ return time.time() class MonotonicTime(Time): - def __init__(self, when): - self._value=when - def realtime(self): return self._value+(time.time()-time.monotonic()) @@ -107,9 +114,6 @@ return time.monotonic() class DreamTime(Time): - def __init__(self, when): - self._value=when - def realtime(self): return self._value+(time.time()-dreamtime()) @@ -123,6 +127,7 @@ def _now(): return dreamtime() + if platform.system()=='Darwin': import Foundation