diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2006-06-08 02:16:13 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2006-06-08 02:16:13 +0000 |
commit | e75a91215c4b5c5946dfc4aaf07da3498c4bb2d3 (patch) | |
tree | 3e32993ba2d316bdc414e3a8af6327b56dd3c3ac /leapsecond.py | |
parent | 981cdc4925753ca62a3a0bdd2bf0d4a17871a66d (diff) | |
download | gpsd-e75a91215c4b5c5946dfc4aaf07da3498c4bb2d3.tar.gz |
Subtract the right offset.
Diffstat (limited to 'leapsecond.py')
-rwxr-xr-x | leapsecond.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/leapsecond.py b/leapsecond.py index dac185c9..565ad5bb 100755 --- a/leapsecond.py +++ b/leapsecond.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Get the current leap-second value. This is the offset between GMT and +# Get the current leap-second value. This is the offset between UTC and # GPS time, which changes occasionally due to variations in the Earth's # rotation. # @@ -11,27 +11,29 @@ __locations = [ # U.S. Navy's offset-history file "ftp://maia.usno.navy.mil/ser7/tai-utc.dat", r" TAI-UTC= +([0-9-]+)[^\n]*\n$", - -1, + 1, + 19, # Magic TAI-GPS offset ), ( # International Earth Rotation Service Bulletin C "http://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat", r" UTC-TAI = ([0-9-]+)", - 1, + -1, + 19, # Magic TAI-GPS offset ), ] def retrieve(): - "Retrieve current leap-second from web sources." + "Retrieve current leap-second from Web sources." random.shuffle(__locations) # To spread the load - for (url, regexp, sign) in __locations: + for (url, regexp, sign, offset) in __locations: try: ifp = urllib.urlopen(url) txt = ifp.read() ifp.close() m = re.search(regexp, txt) if m: - return int(m.group(1)) * sign + return int(m.group(1)) * sign - offset except: pass else: |