Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use utc timezone #77

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/helpers/database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from hexbytes import HexBytes
import psycopg
Expand Down Expand Up @@ -142,7 +142,9 @@ def write_transaction_timestamp(
query,
{
"tx_hash": bytes.fromhex(transaction_timestamp[0][2:]),
"time": datetime.fromtimestamp(transaction_timestamp[1]),
"time": datetime.fromtimestamp(
transaction_timestamp[1], tz=timezone.utc
),
},
)

Expand Down Expand Up @@ -175,7 +177,7 @@ def write_prices_new(self, prices: list[tuple[str, int, float, str]]) -> None:
query,
{
"token_address": bytes.fromhex(token_address[2:]),
"time": datetime.fromtimestamp(time),
"time": datetime.fromtimestamp(time, tz=timezone.utc),
"price": price,
"source": source,
},
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_database.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from hexbytes import HexBytes
from sqlalchemy import create_engine, text
Expand Down Expand Up @@ -31,7 +31,7 @@ def tests_write_transaction_timestamp():
"0x" + bytes(res[0]).hex()
== "0xb75e03b63d4f06c56549effd503e1e37f3ccfc3c00e6985a5aacc9b0534d7c5c"
)
assert res[1].timestamp() == 1728044411
assert res[1].replace(tzinfo=timezone.utc).timestamp() == 1728044411


def tests_write_transaction_tokens():
Expand Down
Loading