From 1b96f6efeaf26787cd7be5446c37581a88489949 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Mon, 28 Nov 2022 11:11:43 -0800 Subject: [PATCH] use utc instead of local tz --- monero/backends/jsonrpc/daemon.py | 10 ++++++---- monero/backends/jsonrpc/wallet.py | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/monero/backends/jsonrpc/daemon.py b/monero/backends/jsonrpc/daemon.py index 3fddd27..79c76e3 100755 --- a/monero/backends/jsonrpc/daemon.py +++ b/monero/backends/jsonrpc/daemon.py @@ -1,5 +1,5 @@ import binascii -from datetime import datetime +from datetime import datetime, timezone from decimal import Decimal import ipaddress import json @@ -150,7 +150,7 @@ def mempool(self): Transaction( hash=tx["id_hash"], fee=from_atomic(tx["fee"]), - timestamp=datetime.fromtimestamp(tx["receive_time"]), + timestamp=datetime.fromtimestamp(tx["receive_time"], timezone.utc), blob=binascii.unhexlify(tx["tx_blob"]), json=json.loads(tx["tx_json"]), confirmations=0, @@ -182,7 +182,7 @@ def block(self, bhash=None, height=None): "blob": res["blob"], "hash": bhdr["hash"], "height": bhdr["height"], - "timestamp": datetime.fromtimestamp(bhdr["timestamp"]), + "timestamp": datetime.fromtimestamp(bhdr["timestamp"], timezone.utc), "version": (bhdr["major_version"], bhdr["minor_version"]), "difficulty": bhdr["difficulty"], "nonce": bhdr["nonce"], @@ -1577,7 +1577,9 @@ def _do_get_transactions(self, hashes, prune): hash=tx["tx_hash"], fee=from_atomic(fee) if fee else None, height=None if tx["in_pool"] else tx["block_height"], - timestamp=datetime.fromtimestamp(tx["block_timestamp"]) + timestamp=datetime.fromtimestamp( + tx["block_timestamp"], timezone.utc + ) if "block_timestamp" in tx else None, output_indices=tx["output_indices"] diff --git a/monero/backends/jsonrpc/wallet.py b/monero/backends/jsonrpc/wallet.py index d12f9fc..3c3470d 100644 --- a/monero/backends/jsonrpc/wallet.py +++ b/monero/backends/jsonrpc/wallet.py @@ -1,5 +1,5 @@ import binascii -from datetime import datetime +from datetime import datetime, timezone import json import logging import operator @@ -231,7 +231,7 @@ def _paymentdict(self, data): result = { "payment_id": None if pid is None else PaymentID(pid), "amount": from_atomic(data["amount"]), - "timestamp": datetime.fromtimestamp(data["timestamp"]) + "timestamp": datetime.fromtimestamp(data["timestamp"], timezone.utc) if "timestamp" in data else None, "note": data.get("note", None), @@ -258,7 +258,7 @@ def _tx(self, data): "fee": from_atomic(data["fee"]) if "fee" in data else None, "key": data.get("key"), "height": data.get("height", data.get("block_height")) or None, - "timestamp": datetime.fromtimestamp(data["timestamp"]) + "timestamp": datetime.fromtimestamp(data["timestamp"], timezone.utc) if "timestamp" in data else None, "blob": binascii.unhexlify(data.get("blob", "")),