diff --git a/garminexport/util.py b/garminexport/util.py index 5b37441..857bf61 100644 --- a/garminexport/util.py +++ b/garminexport/util.py @@ -4,6 +4,7 @@ import codecs import json from datetime import datetime +import dateutil.parser import os export_formats=["json_summary", "json_details", "gpx", "tcx", "fit"] @@ -31,10 +32,9 @@ def export_activity(client, activity_id, destination, activity_summary = client.get_activity_summary(activity_id) # prefix saved activity files with timestamp and activity id - creation_millis = activity_summary["activity"]["uploadDate"]["millis"] - timestamp = datetime.fromtimestamp(int(creation_millis)/1000.0) - filename_prefix = "{}_{}".format( - timestamp.strftime("%Y%m%d-%H%M%S"), activity_id) + start = activity_summary["activity"]["activitySummary"]["BeginTimestamp"]["value"] + timestamp = dateutil.parser.parse(start) + filename_prefix = "{}_{}".format(timestamp.isoformat(), activity_id) path_prefix = os.path.join(destination, filename_prefix) if 'json_summary' in formats: diff --git a/requirements.txt b/requirements.txt index 2f2d5f4..4ecf1b9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ requests==2.4.3 +python-dateutil==2.2