Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions run_page/codoon_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@ def formated_input(
def tcx_output(fit_array, run_data):
# route ID
fit_id = str(run_data["id"])
# local time
fit_start_time_local = run_data["start_time"]
# zulu time
utc = adjust_time_to_utc(to_date(fit_start_time_local), str(get_localzone()))
fit_start_time = utc.strftime("%Y-%m-%dT%H:%M:%SZ")

# Root node
training_center_database = ET.Element(
"TrainingCenterDatabase",
Expand All @@ -154,7 +160,7 @@ def tcx_output(fit_array, run_data):
activities.append(activity)
# Id
activity_id = ET.Element("Id")
activity_id.text = fit_id
activity_id.text = fit_start_time # Codoon use start_time as ID
activity.append(activity_id)
# Creator
activity_creator = ET.Element("Creator")
Expand All @@ -164,13 +170,6 @@ def tcx_output(fit_array, run_data):
activity_creator_name.text = "咕咚"
activity_creator.append(activity_creator_name)
# Lap

# local time
fit_start_time_local = run_data["start_time"]
# zulu time
utc = adjust_time_to_utc(to_date(fit_start_time_local), str(get_localzone()))
fit_start_time = utc.strftime("%Y-%m-%dT%H:%M:%SZ")

activity_lap = ET.Element("Lap", {"StartTime": fit_start_time})
activity.append(activity_lap)
# TotalTimeSeconds
Expand Down
4 changes: 3 additions & 1 deletion run_page/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def to_date(ts):
# shouldn't be an issue since it's an offline cmdline tool
return datetime.strptime(ts, ts_fmt)
except ValueError:
print("Error: Can not execute strptime")
print(
f"Warning: Can not execute strptime {ts} with ts_fmt {ts_fmt}, try next one..."
)
pass

raise ValueError(f"cannot parse timestamp {ts} into date with fmts: {ts_fmts}")
Expand Down