mirror of
https://github.com/elisiariocouto/leggen.git
synced 2025-12-14 13:12:22 +00:00
fix(sync): Use timezone-aware datetime objects.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from datetime import datetime
|
import datetime
|
||||||
|
|
||||||
import click
|
import click
|
||||||
|
|
||||||
@@ -25,8 +25,8 @@ def sync(ctx: click.Context):
|
|||||||
for r in res.get("results", []):
|
for r in res.get("results", []):
|
||||||
account_status = REQUISITION_STATUS.get(r["status"], "UNKNOWN")
|
account_status = REQUISITION_STATUS.get(r["status"], "UNKNOWN")
|
||||||
if account_status != "LINKED":
|
if account_status != "LINKED":
|
||||||
created_at = datetime.fromisoformat(r["created"])
|
created_at = datetime.datetime.fromisoformat(r["created"])
|
||||||
now = datetime.now()
|
now = datetime.datetime.now(tz=datetime.timezone.utc)
|
||||||
if (created_at - now).days <= 15:
|
if (created_at - now).days <= 15:
|
||||||
n = {
|
n = {
|
||||||
"bank": r["institution_id"],
|
"bank": r["institution_id"],
|
||||||
@@ -55,7 +55,7 @@ def sync(ctx: click.Context):
|
|||||||
"amount": amount,
|
"amount": amount,
|
||||||
"currency": balance_amount["currency"],
|
"currency": balance_amount["currency"],
|
||||||
"type": balance["balanceType"],
|
"type": balance["balanceType"],
|
||||||
"timestamp": datetime.now().timestamp(),
|
"timestamp": datetime.datetime.now().timestamp(),
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
persist_balance(ctx, account, balance_document)
|
persist_balance(ctx, account, balance_document)
|
||||||
|
|||||||
Reference in New Issue
Block a user