Skip to content

Commit

Permalink
Adjust timezone handling in an attempt to satisfy tests on CI/GHA
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Nov 19, 2021
1 parent e384b71 commit cd58e50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Expand Up @@ -14,6 +14,7 @@ jobs:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9, '3.10']

name: Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v2

Expand All @@ -22,5 +23,8 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Set timezone
uses: szenius/set-timezone@v1.0

- name: Run tests
run: make test
2 changes: 1 addition & 1 deletion grafanimate/timeutil.py
Expand Up @@ -183,7 +183,7 @@ def convert_absolute_timestamp(value: Union[datetime, str]) -> datetime:
if isinstance(value, datetime):
pass
elif isinstance(value, int):
value = datetime.fromtimestamp(value)
value = datetime.fromtimestamp(value, tz=timezone.utc)
elif isinstance(value, str):
value = dateutil.parser.parse(value)
else:
Expand Down
16 changes: 8 additions & 8 deletions tests/test_model.py
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from dateutil.relativedelta import relativedelta
from dateutil.rrule import DAILY, MINUTELY, SECONDLY
Expand Down Expand Up @@ -74,8 +74,8 @@ def test_sequence_epoch():
mode=SequencingMode.CUMULATIVE,
)

assert seq.start == datetime(2021, 11, 16, 20, 30, 11)
assert seq.stop == datetime(2021, 11, 16, 20, 45, 11)
assert seq.start == datetime(2021, 11, 16, 19, 30, 11, tzinfo=timezone.utc)
assert seq.stop == datetime(2021, 11, 16, 19, 45, 11, tzinfo=timezone.utc)
assert seq.every == "4m5s"
assert seq.mode == SequencingMode.CUMULATIVE

Expand All @@ -85,11 +85,11 @@ def test_sequence_epoch():
assert seq.recurrence.duration == relativedelta(minutes=+4, seconds=+4)

assert list(seq.get_timeranges_isoformat()) == [
"2021-11-16T20:30:11/2021-11-16T20:30:11",
"2021-11-16T20:30:11/2021-11-16T20:34:11",
"2021-11-16T20:30:11/2021-11-16T20:38:11",
"2021-11-16T20:30:11/2021-11-16T20:42:11",
"2021-11-16T20:30:11/2021-11-16T20:46:11",
"2021-11-16T19:30:11+00:00/2021-11-16T19:30:11+00:00",
"2021-11-16T19:30:11+00:00/2021-11-16T19:34:11+00:00",
"2021-11-16T19:30:11+00:00/2021-11-16T19:38:11+00:00",
"2021-11-16T19:30:11+00:00/2021-11-16T19:42:11+00:00",
"2021-11-16T19:30:11+00:00/2021-11-16T19:46:11+00:00",
]


Expand Down

0 comments on commit cd58e50

Please sign in to comment.