forked from season-lab/program-generator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhour.py
More file actions
23 lines (16 loc) · 692 Bytes
/
hour.py
File metadata and controls
23 lines (16 loc) · 692 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from abstract_time import AbstractTime
class Hour(AbstractTime):
def __init__(self, string_hour):
timestamp = AbstractTime.get_timestamp_from_date_hour("1970/01/01", string_hour)
super(Hour, self).__init__(string_hour, timestamp)
assert self.timestamp is not None
def __div__(self, other):
assert not isinstance(other, str)
if isinstance(other, int):
return self.timestamp / other
return self.timestamp / other.timestamp
def __add__(self, other):
assert not isinstance(other, str)
if isinstance(other, int):
return self.timestamp + other
return self.timestamp + other.timestamp