summaryrefslogtreecommitdiff
path: root/leapsecond.py
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2012-01-11 04:42:44 -0500
committerEric S. Raymond <esr@thyrsus.com>2012-01-11 04:47:14 -0500
commitfd802c0a074f81d2c5ac2e604408923f7e2adc3e (patch)
treea26f2e0b80aa47bb2a80aab1dfb6d1b422990736 /leapsecond.py
parent4e6ffa9157ea1e5df02265506152aea40baabb99 (diff)
downloadgpsd-fd802c0a074f81d2c5ac2e604408923f7e2adc3e.tar.gz
Deal properly with scheduled IERS transitions in the future...
...as well as past ones. All regression tests pass.
Diffstat (limited to 'leapsecond.py')
-rwxr-xr-xleapsecond.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/leapsecond.py b/leapsecond.py
index 4848818b..2059f6c4 100755
--- a/leapsecond.py
+++ b/leapsecond.py
@@ -138,10 +138,13 @@ def fetch_leapsecs(filename):
return leapsecs
def make_leapsecond_include(infile):
- leapsecs = fetch_leapsecs(infile)
- leapsecs.append(time.time()) # Add sentinel
+ leapjumps = fetch_leapsecs(infile)
year = time.strftime("%Y", time.localtime(time.time()))
- return ("#define CENTURY_BASE\t%s00\n" % year[:2]) + ("#define LEAPSECOND_NOW\t%d\n" % (len(leapsecs)-2))
+ leapsecs = 0
+ for leapjump in leapjumps:
+ if leapjump < time.time():
+ leapsecs += 1
+ return ("#define CENTURY_BASE\t%s00\n" % year[:2]) + ("#define LEAPSECOND_NOW\t%d\n" % (leapsecs-1))
def leastsquares(tuples):
"Generate coefficients for a least-squares fit to the specified data."