From 49916431cf5f372f35662d2c2c4167ec3d7d95b4 Mon Sep 17 00:00:00 2001 From: Rim Date: Mon, 25 Dec 2023 21:59:55 -0500 Subject: [PATCH] Add timezone for other conversion --- get_cod_stats.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/get_cod_stats.py b/get_cod_stats.py index de6981d..af84daf 100644 --- a/get_cod_stats.py +++ b/get_cod_stats.py @@ -253,17 +253,22 @@ def replace_time_and_duration_recursive(data): else: replace_time_and_duration_recursive(value) -def epoch_milli_to_human_readable(epoch_millis): +def epoch_milli_to_human_readable(epoch_millis, timezone='GMT'): """ - Convert epoch timestamp in milliseconds to human-readable date-time string. + Convert epoch timestamp in milliseconds to a human-readable date-time string with timezone. """ if isinstance(epoch_millis, str): return epoch_millis # Already converted dt_object = datetime.datetime.utcfromtimestamp(epoch_millis / 1000.0) - # date_str = dt_object.strftime("%Y-%m-%d %H:%M:%S") + if timezone == 'GMT': + date_str = dt_object.strftime("GMT: %A, %B %d, %Y %I:%M:%S %p") + elif timezone == 'EST': + dt_object -= datetime.timedelta(hours=4) # Adjust for EST + date_str = dt_object.strftime("EST: %A, %B %d, %Y %I:%M:%S %p") + else: + raise ValueError("Unsupported timezone.") return date_str - def epoch_to_human_readable(epoch_timestamp, timezone='GMT'): if isinstance(epoch_timestamp, str): return epoch_timestamp # Already converted