File tree Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Expand file tree Collapse file tree 2 files changed +5
-9
lines changed Original file line number Diff line number Diff line change 44
55class Slot :
66 @staticmethod
7- def time ():
7+ def time () -> int :
88 """Get the time difference between now and network start.
99
1010 Returns:
1111 int: difference in seconds
1212 """
1313 now = datetime .now (timezone .utc )
1414
15- seconds = int ((now - Slot .epoch ()).total_seconds ())
16-
17- return seconds
15+ return int (now .timestamp () - Slot .epoch ())
1816
1917 @staticmethod
20- def epoch ():
18+ def epoch () -> int :
2119 epoch_str = Network .get_network ().epoch ()
2220 if epoch_str .endswith ("Z" ):
2321 epoch_str = epoch_str [:- 1 ] + "+00:00"
2422
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-
31from crypto .utils .slot import Slot
42
53def test_get_epoch ():
64 result = Slot .epoch ()
7- assert isinstance (result , datetime )
5+ assert isinstance (result , int )
86
97def test_get_time ():
108 result = Slot .time ()
You can’t perform that action at this time.
0 commit comments