Skip to content

Commit

Permalink
fix(sync): Use timezone-aware datetime objects.
Browse files Browse the repository at this point in the history
  • Loading branch information
elisiariocouto committed Jun 7, 2024
1 parent e0351a8 commit 9402c25
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions leggen/commands/sync.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
import datetime

import click

Expand All @@ -25,8 +25,8 @@ def sync(ctx: click.Context):
for r in res.get("results", []):
account_status = REQUISITION_STATUS.get(r["status"], "UNKNOWN")
if account_status != "LINKED":
created_at = datetime.fromisoformat(r["created"])
now = datetime.now()
created_at = datetime.datetime.fromisoformat(r["created"])
now = datetime.datetime.now(tz=datetime.timezone.utc)
if (created_at - now).days <= 15:
n = {
"bank": r["institution_id"],
Expand Down Expand Up @@ -55,7 +55,7 @@ def sync(ctx: click.Context):
"amount": amount,
"currency": balance_amount["currency"],
"type": balance["balanceType"],
"timestamp": datetime.now().timestamp(),
"timestamp": datetime.datetime.now().timestamp(),
}
try:
persist_balance(ctx, account, balance_document)
Expand Down

0 comments on commit 9402c25

Please sign in to comment.