diff --git a/berserk/models.py b/berserk/models.py index 59c4c27..45f3f7f 100644 --- a/berserk/models.py +++ b/berserk/models.py @@ -68,8 +68,8 @@ class Game(Model): class GameState(Model): createdAt = utils.datetime_from_millis - wtime = utils.timedelta_from_milis - btime = utils.timedelta_from_milis + wtime = utils.timedelta_from_millis + btime = utils.timedelta_from_millis winc = utils.datetime_from_millis binc = utils.datetime_from_millis diff --git a/berserk/utils.py b/berserk/utils.py index 7b6373c..5a36430 100644 --- a/berserk/utils.py +++ b/berserk/utils.py @@ -20,6 +20,8 @@ def timedelta_from_millis(millis: float) -> timedelta: for a given milliseconds. """ return timedelta(milliseconds=millis) + + def datetime_from_seconds(ts: float) -> datetime: """Return the datetime for the given seconds since the epoch. diff --git a/tests/test_models.py b/tests/test_models.py index 50bbc94..b8122cc 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,4 +1,4 @@ -from berserk import models +from berserk import models, utils def test_conversion(): @@ -9,17 +9,16 @@ class Example(models.Model): modified = {"foo": 5, "bar": 3, "baz": "4"} assert Example.convert(original) == modified + def test_time_delta(): """test timedelta_from millis""" test_data = 1000.0 - dt1 = datetime_from_millis(test_data) - dt2 = datetime_from_millis(2 * test_data) + dt1 = utils.datetime_from_millis(test_data) + dt2 = utils.datetime_from_millis(2 * test_data) - delta_1 = timedelta_from_millis(test_data) + delta_1 = utils.timedelta_from_millis(test_data) # time delta dt1 dt2 delta_2 = dt2 - dt1 assert delta_1 == delta_2 - -