From 8d75348bb2d8c303f9f1133b9b7dfb054daed332 Mon Sep 17 00:00:00 2001 From: Emily Doherty Date: Sun, 24 Sep 2023 00:46:18 -0700 Subject: [PATCH] Report update times per region and current time to calculate diff in client --- wow-token-current.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wow-token-current.py b/wow-token-current.py index 139e157..1c9ad2b 100644 --- a/wow-token-current.py +++ b/wow-token-current.py @@ -50,12 +50,17 @@ def token_data(version: str) -> dict: items = table.scan()['Items'] data = { - 'current_time': datetime.datetime.utcfromtimestamp(int(items[0]['current_time'])).replace( - tzinfo=datetime.timezone.utc).isoformat(), - 'price_data': {} + 'current_time': datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc).isoformat(timespec="seconds"), + 'price_data': {}, + 'update_times': {}, } for item in items: data['price_data'][item['region']] = int(int(item['price']) / 10000) + data['update_times'][item['region']] = ( + datetime.datetime + .utcfromtimestamp(int(item['current_time'])) + .replace(tzinfo=datetime.timezone.utc).isoformat() + ) return data