c2 stuff now using timezone info
This commit is contained in:
@@ -1076,20 +1076,21 @@ def add_workout_from_data(user,importid,data,strokedata,
|
||||
except: # pragma: no cover
|
||||
comments = ' '
|
||||
|
||||
try:
|
||||
thetimezone = tz(data['timezone'])
|
||||
except:
|
||||
thetimezone = 'UTC'
|
||||
|
||||
thetimezone = pytz.timezone(data['timezone'])
|
||||
|
||||
|
||||
r = Rower.objects.get(user=user)
|
||||
|
||||
try:
|
||||
rowdatetime = iso8601.parse_date(data['date_utc'])
|
||||
thetimezone = 'UTC'
|
||||
except KeyError: # pragma: no cover
|
||||
rowdatetime = iso8601.parse_date(data['start_date'])
|
||||
rowdatetime = rowdatetime.make_aware(thetimezone)
|
||||
except ParseError: # pragma: no cover
|
||||
rowdatetime = iso8601.parse_date(data['date'])
|
||||
|
||||
rowdatetime = rowdatetime.make_aware(thetimezone)
|
||||
|
||||
|
||||
try:
|
||||
@@ -1119,7 +1120,9 @@ def add_workout_from_data(user,importid,data,strokedata,
|
||||
cum_time = res[0]
|
||||
lapidx = res[1]
|
||||
|
||||
starttimeunix = starttimeunix - cum_time.max()
|
||||
totaltime = data['time']/10.
|
||||
starttimeunix = starttimeunix - totaltime
|
||||
|
||||
|
||||
unixtime = cum_time+starttimeunix
|
||||
# unixtime[0] = starttimeunix
|
||||
@@ -1161,7 +1164,6 @@ def add_workout_from_data(user,importid,data,strokedata,
|
||||
velo = 1000./pace
|
||||
pace = 500./velo
|
||||
|
||||
|
||||
# save csv
|
||||
# Create data frame with all necessary data to write to csv
|
||||
df = pd.DataFrame({'TimeStamp (sec)':unixtime,
|
||||
@@ -1223,15 +1225,18 @@ def add_workout_from_data(user,importid,data,strokedata,
|
||||
|
||||
w = Workout.objects.get(id=id)
|
||||
|
||||
local_tz = pytz.timezone(data['timezone'])
|
||||
# local_tz = pytz.timezone(thetimezone)
|
||||
|
||||
w.startdatetime = w.startdatetime.astimezone(local_tz)
|
||||
w.starttime = w.startdatetime.strftime('%H:%M:%S')
|
||||
w.timezone = local_tz
|
||||
|
||||
w.duration = dataprep.totaltime_sec_to_string(totaltime)
|
||||
w.distance = totaldist
|
||||
w.startdatetime = rowdatetime
|
||||
w.starttime = rowdatetime.time()
|
||||
w.date = rowdatetime.date()
|
||||
|
||||
|
||||
w.save()
|
||||
|
||||
|
||||
|
||||
return id,message
|
||||
|
||||
Reference in New Issue
Block a user