-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime_converter.py
More file actions
25 lines (23 loc) · 872 Bytes
/
Copy pathtime_converter.py
File metadata and controls
25 lines (23 loc) · 872 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class TimeConverter:
def __init__(self, unit=0):
self.unit = str(unit)
def __str__(self):
if 's' in self.unit:
self.unit = self.unit.replace('s', '')
elif 'm' in self.unit:
self.unit = self.unit.replace('m', '')
self.unit = int(self.unit) * 60
elif 'h' in self.unit:
self.unit = self.unit.replace('h', '')
self.unit = int(self.unit) * 3600
return str("{}".format(self.unit))
def __int__(self):
if 's' in self.unit:
self.unit = self.unit.replace('s', '')
elif 'm' in self.unit:
self.unit = self.unit.replace('m', '')
self.unit = int(self.unit) * 60
elif 'h' in self.unit:
self.unit = self.unit.replace('h', '')
self.unit = int(self.unit) * 3600
return int(self.unit)