Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nicvagn/berserk
Browse files Browse the repository at this point in the history
  • Loading branch information
nicvagn committed Mar 18, 2024
2 parents f1623c8 + 4c1a1ce commit 69bd3b4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions berserk/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ class GameState(Model):
winc = utils.timedelta_from_millis
binc = utils.timedelta_from_millis


class Tournament(Model):
startsAt = utils.datetime_from_str_or_millis

Expand Down
1 change: 1 addition & 0 deletions berserk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def timedelta_from_millis(millis: float) -> timedelta:
"""
return timedelta(milliseconds=millis)


def datetime_from_seconds(ts: float) -> datetime:
"""Return the datetime for the given seconds since the epoch.
Expand Down
11 changes: 5 additions & 6 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from berserk import models
from berserk import models, utils


def test_conversion():
Expand All @@ -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


0 comments on commit 69bd3b4

Please sign in to comment.