优化时间戳处理,使用本地时区转换以提高准确性

This commit is contained in:
2025-07-28 00:22:36 +08:00
parent 2e9bd0af69
commit 2fdbb94c28

View File

@@ -3,7 +3,7 @@
import json import json
import time import time
import subprocess import subprocess
from datetime import datetime, timezone from datetime import datetime
from collections import defaultdict from collections import defaultdict
import logging import logging
from pathlib import Path from pathlib import Path
@@ -70,9 +70,8 @@ def calculate_daily_stats(transactions):
) )
for tx in transactions: for tx in transactions:
date = datetime.fromtimestamp(tx["blockTimestamp"], timezone.utc).strftime( # 使用本地时区转换时间戳
"%Y-%m-%d" date = datetime.fromtimestamp(tx["blockTimestamp"]).strftime("%Y-%m-%d")
)
price = tx.get("price", 0) price = tx.get("price", 0)
tokens_sold = tx.get("tokensSold", 0) tokens_sold = tx.get("tokensSold", 0)