From a18a06e1fe98ce82a1eb66085071eb8a37a946c7 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Thu, 6 Mar 2025 15:11:03 +0100 Subject: [PATCH] bugfixing --- app/restart_json.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/restart_json.py b/app/restart_json.py index 541a6bb..84f17ff 100755 --- a/app/restart_json.py +++ b/app/restart_json.py @@ -1251,7 +1251,6 @@ async def get_stock_splits_calendar(con,symbols): - async def get_economic_calendar(): ny_tz = pytz.timezone('America/New_York') today = datetime.now(ny_tz) @@ -1283,15 +1282,17 @@ async def get_economic_calendar(): impact = item.get('impact', None) importance = 3 if impact == 'High' else 2 if impact == 'Medium' else 1 - # Convert to UTC - dt_ny = ny_tz.localize(datetime.strptime(item['date'], "%Y-%m-%d %H:%M:%S")) # Assume given time is NY time - dt_utc = dt_ny.astimezone(pytz.UTC) # Convert to UTC + # Parse date as UTC (naive) + dt_utc = datetime.strptime(item['date'], "%Y-%m-%d %H:%M:%S") + + # Convert to New York time + dt_ny = dt_utc - timedelta(hours=5) filtered_data.append({ 'countryCode': country_code, 'country': country, - 'time': dt_utc.strftime("%H:%M"), # UTC Time - 'date': dt_utc.strftime("%Y-%m-%d"), # UTC Date + 'time': dt_ny.strftime("%H:%M"), + 'date': dt_ny.strftime("%Y-%m-%d"), 'prior': item['previous'], 'consensus': item['estimate'], 'actual': item['actual'], @@ -1305,6 +1306,7 @@ async def get_economic_calendar(): return filtered_data + def replace_representative(office): replacements = { 'Knott, Brad (Senator)': 'Brad Knott', @@ -1693,7 +1695,6 @@ async def save_json_files(): ujson.dump(data, file) - con.close() etf_con.close()