diff options
author | Fred Wright <fw@fwright.net> | 2016-04-09 19:57:13 -0700 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2016-04-10 04:58:42 -0400 |
commit | c1fc8432489e10ab08e2fc9c66312343e9245032 (patch) | |
tree | a003114384abb4b22a0a1821ce707901a62472d8 /leapsecond.py | |
parent | 861588f1e7add685a4b1daaee89b08d5f33b3dc0 (diff) | |
download | gpsd-c1fc8432489e10ab08e2fc9c66312343e9245032.tar.gz |
Fixes integer division for Python 3.
This changes a few integer division cases to use the '//'
floored-division operator, matching the normal Python 2 (C-like) '/'
behavior, for compatibility with the switch to the "mathematical"
divison operator in Python 3 (and in Python 2 with the "future
division" import). This was more about keeping the behavior the same
than determining whether floored division is actually the proper
choice.
One place where floored division is definitely wanted is in the GPS
week calculations in leapsecond.py, which are now OK for Python 3,
though currently that module is only used by SConstruct, and hence not
with Python 3.
Two other minor fixes:
1) The GPS base date is corrected in the comment in leapsecond.py.
2) The fit_to_grid() function in xgps now consistently returns floats,
rather than returning either ints or floats depending on the line
width.
TESTED:
Ran "scons build-all check" with all 6 supported Python versions.
Also ran xgps and xgpsspeed with all but 2.6.
Diffstat (limited to 'leapsecond.py')
-rwxr-xr-x | leapsecond.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/leapsecond.py b/leapsecond.py index dcf7b963..3bd13e25 100755 --- a/leapsecond.py +++ b/leapsecond.py @@ -74,17 +74,17 @@ __locations = [ ), ] -GPS_EPOCH = 315964800 # 6 Jan 1981 00:00:00 +GPS_EPOCH = 315964800 # 6 Jan 1980 00:00:00 SECS_PER_WEEK = 60 * 60 * 24 * 7 # Seconds per GPS week ROLLOVER = 1024 # 10-bit week rollover def gps_week(t): - return (t - GPS_EPOCH) / SECS_PER_WEEK % ROLLOVER + return (t - GPS_EPOCH) // SECS_PER_WEEK % ROLLOVER def gps_rollovers(t): - return (t - GPS_EPOCH) / SECS_PER_WEEK / ROLLOVER + return (t - GPS_EPOCH) // SECS_PER_WEEK // ROLLOVER def isotime(s): |