Attempt to parse date string as ISO
This commit is contained in:
7
app.py
7
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))
|
||||
|
||||
Reference in New Issue
Block a user