Commit dba60296 authored by Robert Sebille's avatar Robert Sebille
Browse files

+ and - operators return now an ts_object; error 42 update.

parent 7a03d45f
......@@ -157,27 +157,26 @@ Consider this tips:
### + operator
+ operator: new_ts = ts + nb_seconds
update and return self.ts + nb_seconds
+ operator: ts_object = ts_object + nb_seconds
update self.ts and return ts_object + nb_seconds
Add nb_seconds at timestamp
Tips:
- use dhms2second(d=0, h=0, m=0, s=0) utility method
to convert days + hours + minutes + seconds in seconds
- To add seconds to a new timestamp instance:
new_ts_object = ts_object.copy()
new_ts_object - seconds
new_ts_object - nb_seconds
### - operator
- operator: new_ts = ts_object - *nb_seconds_or_ts_object
if *nb_seconds_or_ts_object is a nb_seconds integer
update and return self.ts - *nb_seconds
update self.ts and return ts_object - *nb_seconds
self.ts seconds - seconds must be >= 0 (epoch-01-01)
if *nb_seconds_or_ts_object is ts_object, call
self.ts.diffDays("string", *nb_seconds_or_ts_object.get_ts())
self.ts is NOT updated.
_See this method above_
self.ts is NOT updated. See diffDays() method above.
Tips:
- use dhms2second(d=0, h=0, m=0, s=0) utility method
......
......@@ -89,11 +89,13 @@ class AaaaHorodatageTools(AaaaHorodatage):
# protected #
# attributs
def _get_Aaaa42(self):
print(self._Aaaa42)
douglas = open("aaaa/42", "r")
print(douglas.read())
douglas.close()
print("\nFatal error 42: existential error 101010.\nSystem halted.")
sys.exit(42)
Aaaa42 = property(_get_Aaaa42)
_42 = property(_get_Aaaa42)
# Special #
def copy(self):
......@@ -148,7 +150,7 @@ class AaaaHorodatageTools(AaaaHorodatage):
return self.get_ts()
def __add__(self, seconds=0):
"""Add seconds to self.ts and return self.ts.
"""new_ts = ts_object + seconds.
Overload of plus operator.
self.ts will be updated
......@@ -168,7 +170,7 @@ class AaaaHorodatageTools(AaaaHorodatage):
ts_seconds = int(tmp / 10000)
ts_seconds += seconds
self.ts = str(ts_seconds) + str(ts_epoch) + "Z" + ts_offset
return self.ts
return self
def __sub__(self, *nb_seconds_or_ts_object):
"""new_ts = ts_object - *nb_seconds_or_ts_object
......@@ -209,7 +211,7 @@ class AaaaHorodatageTools(AaaaHorodatage):
print("Program halted.")
sys.exit(53)
self.ts = str(ts_seconds) + str(ts_epoch) + "Z" + ts_offset
return self.ts
return self
# protected #
# méthodes
......
......@@ -138,6 +138,8 @@ if __name__ == "__main__":
print(myDT.decode(), " <= ", myKb.decode(), ": ", myDT <= myKb)
print(myDT.decode(), " > ", myKb.decode(), ": ", myDT > myKb)
print(myDT.decode(), " >= ", myKb.decode(), ": ", myDT >= myKb)
print("(", myDT.decode(), " + 10T01:10:20) > ", myKb.decode(), ": ",
(myDT + myDT.dhms2seconds(10, 1, 10, 20)) > myKb)
rep = True
while rep:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment