Skip to content

Commit

Permalink
Update rounding of playback time to nearest second (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
aywaldron committed Nov 12, 2019
1 parent 3d0f2dd commit 39e9422
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions ait/gui/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1078,11 +1078,10 @@ def handle():
start_time = points[0]['time'][:19] + 'Z'
ranges[i].append(start_time)
# Round end time up to nearest second
end_time = points[len(points) - 1]['time'][:23] + 'Z'
dt = datetime.strptime(end_time, '%Y-%m-%dT%H:%M:%S.%fZ')
if dt.microsecond != 0:
dt += timedelta(0, 1)
end_time = dt.strftime('%Y-%m-%dT%H:%M:%SZ')
time_split = points[len(points) - 1]['time'].split('.')
second = int(round(float(time_split[1][:-1]) / 10**9))
end_time = datetime.strptime(time_split[0], '%Y-%m-%dT%H:%M:%S') + timedelta(seconds=second)
end_time = end_time.strftime('%Y-%m-%dT%H:%M:%SZ')
ranges[i].append(end_time)

return json.dumps(ranges)
Expand Down

0 comments on commit 39e9422

Please sign in to comment.