File tree 2 files changed +5
-9
lines changed
2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 4
4
5
5
class Slot :
6
6
@staticmethod
7
- def time ():
7
+ def time () -> int :
8
8
"""Get the time difference between now and network start.
9
9
10
10
Returns:
11
11
int: difference in seconds
12
12
"""
13
13
now = datetime .now (timezone .utc )
14
14
15
- seconds = int ((now - Slot .epoch ()).total_seconds ())
16
-
17
- return seconds
15
+ return int (now .timestamp () - Slot .epoch ())
18
16
19
17
@staticmethod
20
- def epoch ():
18
+ def epoch () -> int :
21
19
epoch_str = Network .get_network ().epoch ()
22
20
if epoch_str .endswith ("Z" ):
23
21
epoch_str = epoch_str [:- 1 ] + "+00:00"
24
22
25
- return datetime .fromisoformat (epoch_str )
23
+ return int ( datetime .fromisoformat (epoch_str ). timestamp () )
Original file line number Diff line number Diff line change 1
- from datetime import datetime
2
-
3
1
from crypto .utils .slot import Slot
4
2
5
3
def test_get_epoch ():
6
4
result = Slot .epoch ()
7
- assert isinstance (result , datetime )
5
+ assert isinstance (result , int )
8
6
9
7
def test_get_time ():
10
8
result = Slot .time ()
You can’t perform that action at this time.
0 commit comments