Skip to content

Instantly share code, notes, and snippets.

@schinckel
Created May 22, 2012 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schinckel/2768802 to your computer and use it in GitHub Desktop.
Save schinckel/2768802 to your computer and use it in GitHub Desktop.
Increment all of the dates within a TCX file by a certain amount.
import re
import datetime
time_re = re.compile('(?P<dt>\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2})')
offset = datetime.timedelta(minutes=5,seconds=1)
for line in lines:
if time_re.search(line):
time = datetime.datetime.strptime(time_re.search(line).groupdict()['dt'], "%Y-%m-%dT%H:%M:%S")
time = time + offset
line = time.strftime("<Time>%Y-%m-%dT%H:%M:%SZ</Time>")
print line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment