Skip to content

Instantly share code, notes, and snippets.

@jshiell
Created April 9, 2015 19:06
Show Gist options
  • Save jshiell/e8405fe9d27b58afcb2b to your computer and use it in GitHub Desktop.
Save jshiell/e8405fe9d27b58afcb2b to your computer and use it in GitHub Desktop.
A quick & dirty script to annotate GPX with fake time data, so you can import it into Strava.
#!/usr/bin/env ruby
require 'rexml/document'
require 'rexml/element'
doc = REXML::Document.new(File.open('London_Classic_2015.gpx', 'r'))
second = 0
min = 0
hour = 1
doc.elements.each('//trkpt') do |point|
time = REXML::Element.new('time')
time.text = "2013-05-11T%s:%s:%sZ" % [hour.to_s.rjust(2, "0"), min.to_s.rjust(2, "0"), second.to_s.rjust(2, "0")]
second += 1
if second > 59
second = 0
min += 1
end
if min > 59
min = 0
hour += 1
end
point.add time
end
doc.write(File.open('out.gpx', 'w'), 2)
@IamWillBg
Copy link

This doesn't work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment