Skip to content

Instantly share code, notes, and snippets.

@8cH9azbsFifZ
Created November 8, 2019 00:21
Show Gist options
  • Save 8cH9azbsFifZ/eb46ed521a8b68627cf0911e8ae83b8a to your computer and use it in GitHub Desktop.
Save 8cH9azbsFifZ/eb46ed521a8b68627cf0911e8ae83b8a to your computer and use it in GitHub Desktop.
Handle timestamp_16 fields in Garmin FIT files
#!/usr/bin/python
from datetime import datetime
import pytz
# https://stackoverflow.com/questions/57774180/how-to-handle-timestamp-16-in-garmin-devices
# http://www.nlvocables.com/blog/?p=969
dt_offset = datetime(2019,4,30,22,0,0,0)
print (dt_offset)
timestamp = int(datetime.timestamp(dt_offset)) - 631065600
print (timestamp)
timestamp_16 = 31132
print (timestamp_16)
mesgTimestamp = timestamp
mesgTimestamp += ( timestamp_16 - ( mesgTimestamp & 0xFFFF ) ) & 0xFFFF
print (mesgTimestamp)
print('New:', datetime.fromtimestamp(mesgTimestamp + 631065600, pytz.timezone('Europe/Zurich')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment