Fixing Garmin TCX Files

I recently bought the new Garmin 520 cycling computer. It’s pretty great, except for one fatal flaw… on a few occasions now, I’ve returned home to discover that the 520 believes I’m some kind of time traveller, magically heading 4 years into the future and back again during my ride.

Of course, these weird timestamps end up corrupting the file — you won’t get any good data out of Garmin Connect, and Strava won’t even let you upload a file that’s so broken.

So I took to python to pull a little script together that parses the TCX file, looks for time deltas greater than 1 second, and fixes the time stamp.

If it’s of use to any one, I’ve put it over on github: