add dt_utc helper

This commit is contained in:
Matthias
2023-05-14 17:36:53 +02:00
parent c0713eb77f
commit 915cb5ffbd
3 changed files with 17 additions and 3 deletions

View File

@@ -3,7 +3,7 @@ from datetime import datetime, timedelta, timezone
import pytest
import time_machine
from freqtrade.util import dt_floor_day, dt_from_ts, dt_now, dt_ts
from freqtrade.util import dt_floor_day, dt_from_ts, dt_now, dt_ts, dt_utc
def test_dt_now():
@@ -21,6 +21,13 @@ def test_dt_now():
assert dt_ts(now) == int(now.timestamp() * 1000)
def test_dt_utc():
assert dt_utc(2023, 5, 5) == datetime(2023, 5, 5, tzinfo=timezone.utc)
assert dt_utc(2023, 5, 5, 0, 0, 0, 555500) == datetime(2023, 5, 5, 0, 0, 0, 555500,
tzinfo=timezone.utc)
@pytest.mark.parametrize('as_ms', [True, False])
def test_dt_from_ts(as_ms):
multi = 1000 if as_ms else 1