From 60a7ec3d15984e8d5a37c3e1054f3011f4a1331a Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Mon, 31 Jul 2023 13:22:39 +1000 Subject: [PATCH] Attempt to parse date string as ISO --- app.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 6960b14..9696d55 100644 --- a/app.py +++ b/app.py @@ -9,6 +9,7 @@ import matplotlib.pyplot as plt import matplotlib.dates as mdates import os import sparklines +from dateutil.parser import isoparse app = Flask(__name__) @@ -164,7 +165,7 @@ def workouts(user_id): db.session.add(heart_rate_reading) if cadence_readings: - timestamps = [datetime_converter( + timestamps = [isoparse( c['timestamp']) for c in cadence_readings] start_time = min(timestamps) end_time = max(timestamps) @@ -435,10 +436,6 @@ def format_duration(duration): return f"{minutes}m" -def datetime_converter(datetime_str: str) -> datetime: - return datetime.strptime(datetime_str, "%Y-%m-%dT%H:%M:%S%z") - - if __name__ == '__main__': # Bind to PORT if defined, otherwise default to 5000. port = int(os.environ.get('PORT', 5000))