Private
Public Access
1
0

further timezone magic c2

This commit is contained in:
Sander Roosendaal
2021-05-12 08:52:51 +02:00
parent 4afaa5fd10
commit 4db0c20efa
4 changed files with 27 additions and 19 deletions

View File

@@ -419,7 +419,7 @@ def handle_c2_import_stroke_data(c2token,
duration = datetime.datetime.strptime(duration,'%H:%M:%S.%f').time()
try:
timezone_str = tz(workoutdata['timezone'])
timezone_str = workoutdata['timezone']
except:
timezone_str = 'UTC'
@@ -2991,7 +2991,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
c2id = data['id']
workouttype = data['type']
verified = data['verified']
startdatetime = iso8601.parse_date(data['date'])
startdatetime = iso8601.parse_date(data['date_utc'])
weightclass = data['weight_class']
try:
@@ -3013,21 +3013,18 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
totaltime = data['time']/10.
duration = totaltime_sec_to_string(totaltime)
starttimeunix = arrow.get(startdatetime).timestamp()-totaltime
startdatetime = arrow.get(starttimeunix)
try:
timezone_str = tz(data['timezone'])
except:
timezone_str = defaulttimezone
timezone = pytz.timezone(data['timezone'])
startdatetime = startdatetime.astimezone(timezone)
startdatetime = startdatetime.replace(tzinfo=None)
tz = pytz.timezone(timezone_str)
startdatetime = tz.localize(startdatetime)
workoutdate = startdatetime.astimezone(
pytz.timezone(timezone_str)
timezone
).strftime('%Y-%m-%d')
starttime = startdatetime.astimezone(
pytz.timezone(timezone_str)
timezone
).strftime('%H:%M:%S')
try:
@@ -3056,8 +3053,6 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
cum_time = res[0]
lapidx = res[1]
starttimeunix = arrow.get(startdatetime).timestamp()
starttimeunix = starttimeunix-cum_time.max()
unixtime = cum_time+starttimeunix
# unixtime[0] = starttimeunix
@@ -3134,6 +3129,7 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
'workouttype':workouttype,
'boattype':'1x',
'c2id':c2id,
'timezone':str(timezone)
}
session = requests.session()
@@ -3165,8 +3161,11 @@ def handle_c2_async_workout(alldata,userid,c2token,c2id,delaysec,defaulttimezone
parkedids = []
with open('c2blocked.json','r') as c2blocked:
jsondata = json.load(c2blocked)
parkedids = jsondata['ids']
try:
jsondata = json.load(c2blocked)
parkedids = jsondata['ids']
except JSONDecodeError:
parkedids = []
newparkedids = [id for id in parkedids if id != newc2id]
with open('c2blocked.json','wt') as c2blocked:
@@ -3364,7 +3363,7 @@ def fetch_strava_workout(stravatoken,oauth_data,stravaid,csvfilename,userid,debu
comments = ' '
try:
thetimezone = tz(workoutsummary['timezone'])
thetimezone = workoutsummary['timezone']
except:
thetimezone = 'UTC'