Add pace to output

This commit is contained in:
William Pettersson 2025-03-31 17:50:24 +01:00
parent 9f3ef9e0e1
commit 4bc6b618f9

View file

@ -172,7 +172,8 @@ def summarise(descr=""):
continue continue
time = make_pretty_td(duration) time = make_pretty_td(duration)
speed = exer['distance'] / (exer['time'] / 3600) speed = exer['distance'] / (exer['time'] / 3600)
s = f"{exer['describe']:7} {exer['distance']:6.2f} km in {time} ({speed:>5.2f} km/h)" pace = f"{int(60 / speed)}:{round((3600/speed) % 60):>02.0f}"
s = f"{exer['describe']:7} {exer['distance']:6.2f} km in {time} ({speed:>5.2f} km/h) ({pace} m/km)"
if descr: if descr:
s += f" ({descr})" s += f" ({descr})"
print(s) print(s)
@ -369,7 +370,8 @@ def textout(start=datetime.date.today().replace(day=1), end=(datetime.date.today
except ValueError: except ValueError:
date = datetime.datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S.%f') date = datetime.datetime.strptime(date_str, '%Y-%m-%d %H:%M:%S.%f')
if each: if each:
s = f"{exer_type(dist, time, speed, date):7} on {date.strftime('%d %b, %H:%M')} {dist:6.2f} km in {make_pretty_td(time)} ({speed:>5.2f} km/h)" pace = f"{int(60 / speed)}:{round((3600/speed) % 60):>02.0f}"
s = f"{exer_type(dist, time, speed, date):7} on {date.strftime('%d %b, %H:%M')} {dist:6.2f} km in {make_pretty_td(time)} ({speed:>5.2f} km/h) ({pace} m/km)"
print(s) print(s)
else: else:
dists[exer_type(dist, time, speed, date)] += dist dists[exer_type(dist, time, speed, date)] += dist
@ -380,7 +382,8 @@ def textout(start=datetime.date.today().replace(day=1), end=(datetime.date.today
continue continue
time = make_pretty_td(duration) time = make_pretty_td(duration)
speed = dists[exer['describe']] / (duration / 3600) speed = dists[exer['describe']] / (duration / 3600)
s = f"{exer['describe']:7} {dists[exer['describe']]:6.2f} km in {time} ({speed:>5.2f} km/h)" pace = f"{int(60 / speed)}:{round((3600/speed) % 60):>02.0f}"
s = f"{exer['describe']:7} {dists[exer['describe']]:6.2f} km in {time} ({speed:>5.2f} km/h) ({pace} m/km)"
print(s) print(s)