Rounding issue when computing avg pace for intervals

Issue #524 resolved
Carlos Reategui created an issue

See the pace for interval #1 in the following workout: https://www.rowsandall.com/rowers/workout/faa0a261/

It is displaying as 1:60.0 instead of what I am guessing should be 2:00.0.

        Workout Summary - media/2464cc92af-20200304-230422o.csv
--|Total|-Total----|--Avg--|-Avg-|Avg-|-Avg-|-Max-|-Avg
--|Dist-|-Time-----|-Pace--|-Pwr-|SPM-|-HR--|-HR--|-DPS
--|12743|00:57:35.9|02:15.6|000.0|22.5|000.0|000.0|09.8
W-|07410|00:29:55.0|02:01.1|000.0|25.8|000.0|000.0|09.6
R-|05335|00:27:41.3|02:35.7|000.0|19.0|000.0|000.0|11.4
Workout Details
#-|SDist|-Split-|-SPace-|-Pwr-|SPM-|AvgHR|MaxHR|DPS-
01|02579|10:18.8|01:60.0|000.0|26.7|000.0|0.0|09.4
02|02431|09:46.4|02:00.6|000.0|25.7|000.0|0.0|09.7
03|02400|09:49.8|02:02.9|000.0|25.0|000.0|0.0|09.8

Comments (3)

  1. Sander Roosendaal repo owner

    Instead of doing any rounding could you use the datetime module?  Something like this (assuming you use python for this):

    from datetime import datetime secs=119.55 secstime= datetime.fromtimestamp(secs + 0.05) stime = '%s.%i' % (secstime.strftime("%M:%S"), secstime.microsecond/100000) print(stime)

    Should round to the nearest tenth of a second.

  2. Sander Roosendaal repo owner

    I could use the datetime module. I likely didn’t do that because this is hitting one of the older parts of the code, when my knowledge base consisted of python + numpy. I am using a simple divmod to get seconds and minutes.

    At the same time, part of this may be moved to golang, in which case we’ll have to investigate again.

  3. Log in to comment