diff --git a/rowers/c2stuff.py b/rowers/c2stuff.py index d09dea9e..75e5952a 100644 --- a/rowers/c2stuff.py +++ b/rowers/c2stuff.py @@ -258,7 +258,7 @@ def createc2workoutdata_as_splits(w): "date": w.startdatetime.isoformat(), "distance": int(w.distance), "time": int(10*makeseconds(durationstr)), - "timezone": "Etc/UTC", + "timezone": w.timezone, "weight_class": c2wc(w.weightcategory), "comments": newnotes, "heart_rate": { @@ -320,7 +320,7 @@ def createc2workoutdata(w): data = { "type": workouttype, "date": w.startdatetime.isoformat(), - "timezone": "Etc/UTC", + "timezone": w.timezone, "distance": int(w.distance), "time": int(10*makeseconds(durationstr)), "weight_class": c2wc(w.weightcategory), diff --git a/rowers/runkeeperstuff.py b/rowers/runkeeperstuff.py index 38a01d82..512cd1a9 100644 --- a/rowers/runkeeperstuff.py +++ b/rowers/runkeeperstuff.py @@ -2,6 +2,7 @@ # Python import oauth2 as oauth +import pytz import cgi import requests import requests.auth @@ -231,7 +232,8 @@ def createrunkeeperworkoutdata(w): } distancedata.append(point) - start_time = w.startdatetime.strftime("%a, %d %b %Y %H:%M:%S") + st = w.startdatetime.astimezone(pytz.timezone(w.timezone)) + start_time = st.strftime("%a, %d %b %Y %H:%M:%S") try: newnotes = w.notes+'\n from '+w.workoutsource+' via rowsandall.com' diff --git a/rowers/sporttracksstuff.py b/rowers/sporttracksstuff.py index 06718912..4e9888c0 100644 --- a/rowers/sporttracksstuff.py +++ b/rowers/sporttracksstuff.py @@ -16,6 +16,7 @@ from math import sin,cos,atan2,sqrt import urllib import c2stuff +import pytz # Django from django.shortcuts import render_to_response @@ -214,6 +215,8 @@ def get_sporttracks_workout(user,sporttracksid): # Create Workout Data for upload to SportTracks def createsporttracksworkoutdata(w): + timezone = pytz.timezone(w.timezone) + filename = w.csvfilename try: row = rowingdata(filename) @@ -283,12 +286,14 @@ def createsporttracksworkoutdata(w): except TypeError: w.notes = 'from '+w.workoutsource+' via rowsandall.com' + st = w.startdatetime.astimezone(timezone) + st = st.replace(microsecond=0) + if haslatlon: data = { "type": "Rowing", "name": w.name, -# "start_time": str(w.date)+"T"+str(w.starttime)+"Z", - "start_time": w.startdatetime.isoformat(), + "start_time": st.isoformat(), "total_distance": int(w.distance), "duration": duration, "notes": w.notes, @@ -303,8 +308,7 @@ def createsporttracksworkoutdata(w): data = { "type": "Rowing", "name": w.name, -# "start_time": str(w.date)+"T"+str(w.starttime)+"Z", - "start_time": w.startdatetime.isoformat(), + "start_time": st.isoformat(), "total_distance": int(w.distance), "duration": duration, "notes": w.notes, diff --git a/rowers/tpstuff.py b/rowers/tpstuff.py index d27d94c5..511e14ab 100644 --- a/rowers/tpstuff.py +++ b/rowers/tpstuff.py @@ -12,6 +12,7 @@ from datetime import timedelta import numpy as np from dateutil import parser import time +import pytz import math import gzip from math import sin,cos,atan2,sqrt diff --git a/rowers/underarmourstuff.py b/rowers/underarmourstuff.py index 0b5a6a7a..6bef0d96 100644 --- a/rowers/underarmourstuff.py +++ b/rowers/underarmourstuff.py @@ -3,6 +3,7 @@ # Python import oauth2 as oauth import cgi +import pytz import requests import requests.auth import json @@ -285,7 +286,8 @@ def createunderarmourworkoutdata(w): for e in zip(t,spm): spmdata.append([e[0],e[1]]) - start_time = w.startdatetime.isoformat() + st = w.startdatetime.astimezone(pytz.timezone(w.timezone)) + start_time = st.isoformat() timeseries = { "distance": distancedata,