Skip to content

Instantly share code, notes, and snippets.

@michel47

michel47/README.md

Last active Feb 28, 2021
Embed
What would you like to do?
Leap Second List Verification (SHA1)
qmleaps sha1 ntp_mod ntp_exp ntp_offset
Qmet9TULQgmm3gE55BA8Htia7brVtQnVX6YZiSyDzhZ6Jk
89073fa89e913fd760559aa529d1feee5b0f6c91
3819011916
3849638400
2208992400

Verifying leap-seconds list file

The perl script 'leapssha1.pl' is computing the hash (sha1) of the data within a leap-seconds.list file in order to verify it's integrity.

We put the list on the blockchain current file is at

https://ipfs.io/ipns/{site.k5mut} and http://127.0.0.1:8080/ipfs/{{page.qmleaps}} https://dweb.link/ipfs/f01551114{{page.sha1}}

sha1: {{page.sha1}} qm: {{page.qmleaps}}

it expires on {{page.data.leaps.ntp_exp | minus: page.ntp_offset | date_to_rfc822 }}

set -x
url=https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list
curl -sL $url | tee leaps-obspm.list | perl leapssha1.pl

url=https://www.ietf.org/timezones/data/leap-seconds.list
curl -sL $url | tee leaps-ietf.list | perl leapssha1.pl

url=https://data.iana.org/time-zones/code/leap-seconds.list
curl -sL $url | tee leaps-iana.list | perl leapssha1.pl

+Dr IT

--- # config
k5mut: k51qzi5uqu5dkdj4vchj90miegpapvgcfvzelm9xocal9ysk2iek6ncfxnvvcg
---
ntp_offset: 2208992400
git_org: https://github.com/ColoredZone
git_repo: https://github.com/ColoredZone/leaps
---
#
# This file is the leap-seconds.list file.
#
# It containts a table of correction to compute
# Atomic Time from UTC:
#
# TAI = UTC + DTAI
# UT1 = UTC + DU1
#
# it was modified on {{site.data.leaps.ntp_mod | minus: page.ntp_offset | date_to_rfc822 }}
#$ {{site.data.leaps.ntp_mod}}
# and expires on {{site.data.leaps.ntp_exp | minus: page.ntp_offset | date_to_rfc822 }}
#@ {{site.data.leaps.ntp_exp}}
#
# a json file is available here : <{{page.git_org}}/leaps/leap-seconds.json>
# a yaml file is available here : <{{page.git_org}}/leaps/leap-seconds.json>
#
#
# list: "{{site.data.leaps.list}}"
# sha1: {{site.data.leaps.sha1}}
#
# LIST OF LEAP SECONDS
# NTP Time is the number of seconds since 1 Jan 1900 00:00:00
#
# DTAI: The difference DTAI= TAI-UTC in units of seconds
# It is the quantity to add to UTC to get the time in TAI
#
# Day Month Year : epoch in clear
#
# NTP Time DTAI Day Month Year
#
2272060800 10 # 1 Jan 1972
2287785600 11 # 1 Jul 1972
2303683200 12 # 1 Jan 1973
2335219200 13 # 1 Jan 1974
2366755200 14 # 1 Jan 1975
2398291200 15 # 1 Jan 1976
2429913600 16 # 1 Jan 1977
2461449600 17 # 1 Jan 1978
2492985600 18 # 1 Jan 1979
2524521600 19 # 1 Jan 1980
2571782400 20 # 1 Jul 1981
2603318400 21 # 1 Jul 1982
2634854400 22 # 1 Jul 1983
2698012800 23 # 1 Jul 1985
2776982400 24 # 1 Jan 1988
2840140800 25 # 1 Jan 1990
2871676800 26 # 1 Jan 1991
2918937600 27 # 1 Jul 1992
2950473600 28 # 1 Jul 1993
2982009600 29 # 1 Jul 1994
3029443200 30 # 1 Jan 1996
3076704000 31 # 1 Jul 1997
3124137600 32 # 1 Jan 1999
3345062400 33 # 1 Jan 2006
3439756800 34 # 1 Jan 2009
3550089600 35 # 1 Jul 2012
3644697600 36 # 1 Jul 2015
3692217600 37 # 1 Jan 2017
#
#
# ATOMIC TIME.
# The Coordinated Universal Time (UTC) is the reference time scale derived
# from The "Temps Atomique International" (TAI) calculated by the Bureau
# International des Poids et Mesures (BIPM) using a worldwide network of atomic
# clocks. UTC differs from TAI by an integer number of seconds; it is the basis
# of all activities in the world.
#
# ASTRONOMICAL TIME (UT1) is the time scale based on the rate of rotation of the earth.
# It is now mainly derived from Very Long Baseline Interferometry (VLBI). The various
# irregular fluctuations progressively detected in the rotation rate of the Earth lead
# in 1972 to the replacement of UT1 by UTC as the reference time scale.
#
# RESPONSABILITY OF THE DECISION TO INTRODUCE A LEAP SECOND IN UTC
# The decision to introduce a leap second in UTC is the responsibility of the Earth Orientation Center of
# the International Earth Rotation and reference System Service (IERS). This center is located at Paris
# Observatory. According to international agreements, leap seconds should only be scheduled for certain dates:
# first preference is given to the end of December and June, and second preference at the end of March
# and September. Since the introduction of leap seconds in 1972, only dates in June and December were used.
#
# Questions or comments to:
# Christian Bizouard: <christian.bizouard@obspm.fr>
# Earth orientation Center of the IERS
# Paris Observatory, France
#
# A hash code (SHA1) has been generated to be able to verify the integrity
# of this file. For more information about using this hash code,
# see the [README]({{page.gist_url}}/README.md) file
#
# sha1: {{site.data.leaps.sha1}}
#
#h 89073fa8 9e913fd7 60559aa5 29d1feee 5b0f6c91
#
# itent: quick verification of 3 trusted files ...
set -x
url=https://hpiers.obspm.fr/iers/bul/bulc/ntp/leap-seconds.list
curl -sL $url | tee leaps-obspm.list | perl leapssha1.pl
url=https://www.ietf.org/timezones/data/leap-seconds.list
curl -sL $url | tee leaps-ietf.list | perl leapssha1.pl
url=https://data.iana.org/time-zones/code/leap-seconds.list
curl -sL $url | tee leaps-iana.list | perl leapssha1.pl
true; # $Source: /my/shell/scripts/leaps.sh$
#!/usr/bin/perl
# intent: verify a leap-seconds.list file
use Digest::SHA1 qw();
my $msg = Digest::SHA1->new();
printf "--- # %s\n",$0;
my $sha1;
while (<>) {
chomp;
if (m/^#\$/) {
$update = (split(/[ \t]+/))[1];
printf "update: %u -- MJD: %.1f; %s\n",$update,MJD($update),NTPdate($update);
$msg->add($update);
} elsif (m/^#@/) {
$expire = (split(/[ \t]+/))[1];
printf "expire: %u -- MJF: %.1f; %s\n",$expire,MJD($expire),NTPdate($expire);
$msg->add("$expire");
} elsif (! m/^#/) {
($date,$dut) = split(/[ \t]+/);
printf "dut: %u # ntp: %u -- MJD: %.1f %s\n",$dut,$date,MJD($date+$dut),NTPdate($date+$dut);
$msg->add("$date");
$msg->add("$dut");
} elsif (m/^#h/) {
my (undef,@nybs) = split(/[ \t]+/);
$sha1 = join'',map { substr('0'x8 . $_,-8); } @nybs;
printf "sha1: %s\n",$sha1;
}
}
my $digest = $msg->hexdigest();
printf "digest: %s\n",$digest;
die sprintf"error: digest != %s",$sha1 if ($digest ne $sha1);
print "...\n";
exit $?;
sub MJD { # Modified Julian Day Number
return $_[0] / 86400 + 15020;
}
sub NTPdate {
# NTP timestamp 1 July 1972
my $ntp_offset = 2287785600-78793200;
my $ntic = shift;
return sdate($ntic - $ntp_offset);
}
sub sdate { # return a human readable date ... but still sortable ...
my $tic = int ($_[0]);
my $ms = ($_[0] - $tic) * 1000;
$ms = ($ms) ? sprintf('%04u',$ms) : '____';
my ($sec,$min,$hour,$mday,$mon,$yy) = (localtime($tic))[0..5];
my ($yr4,$yr2) =($yy+1900,$yy%100);
my $date = sprintf '%04u-%02u-%02u %02u.%02u.%02u',
$yr4,$mon+1,$mday, $hour,$min,$sec;
return $date;
}
1; # $Source: /my/perl/scripts/leapssha1.pl$
# ATOMIC TIME.
# The Coordinated Universal Time (UTC) is the reference time scale derived
# from The "Temps Atomique International" (TAI) calculated by the Bureau
# International des Poids et Mesures (BIPM) using a worldwide network of atomic
# clocks. UTC differs from TAI by an integer number of seconds; it is the basis
# of all activities in the world.
#
#
# ASTRONOMICAL TIME (UT1) is the time scale based on the rate of rotation of the earth.
# It is now mainly derived from Very Long Baseline Interferometry (VLBI). The various
# irregular fluctuations progressively detected in the rotation rate of the Earth lead
# in 1972 to the replacement of UT1 by UTC as the reference time scale.
#
#
# LEAP SECOND
# Atomic clocks are more stable than the rate of the earth rotation since the latter
# undergoes a full range of geophysical perturbations at various time scales: lunisolar
# and core-mantle torques, atmospheric and oceanic effetcs, etc.
# Leap seconds are needed to keep the two time scales in agreement, i.e. UT1-UTC smaller
# than 0.9 second. Therefore, when necessary a "leap second" is applied to UTC.
# Since the adoption of this system in 1972 it has been necessary to add a number of seconds to UTC,
# firstly due to the initial choice of the value of the second (1/86400 mean solar day of
# the year 1820) and secondly to the general slowing down of the Earth's rotation. It is
# theorically possible to have a negative leap second (a second removed from UTC), but so far,
# all leap seconds have been positive (a second has been added to UTC). Based on what we know about
# the earth's rotation, it is unlikely that we will ever have a negative leap second.
#
#
# HISTORY
# The first leap second was added on June 30, 1972. Until yhe year 2000, it was necessary in average to add a
# leap second at a rate of 1 to 2 years. Since the year 2000 leap seconds are introduced with an
# average interval of 3 to 4 years due to the acceleration of the Earth rotation speed.
#
#
# RESPONSABILITY OF THE DECISION TO INTRODUCE A LEAP SECOND IN UTC
# The decision to introduce a leap second in UTC is the responsibility of the Earth Orientation Center of
# the International Earth Rotation and reference System Service (IERS). This center is located at Paris
# Observatory. According to international agreements, leap seconds should only be scheduled for certain dates:
# first preference is given to the end of December and June, and second preference at the end of March
# and September. Since the introduction of leap seconds in 1972, only dates in June and December were used.
#
# Questions or comments to:
# Christian Bizouard: christian.bizouard@obspm.fr
# Earth orientation Center of the IERS
# Paris Observatory, France
#
#
#
#
# VALIDITY OF THE FILE
# It is important to express the validity of the file. These next two dates are
# given in units of seconds since 1900.0.
#
# 1) Last update of the file.
#
# Updated through IERS Bulletin C (ftp://hpiers.obspm.fr/iers/bul/bulc/bulletinc.dat)
#
# The following line shows the last update of this file in NTP timestamp:
#
#$ 3819011916
#
# 2) Expiration date of the file given on a semi-annual basis: last June or last December
#
# File expires on 28 December 2021
#
# Expire date in NTP timestamp:
#
#@ 3849638400
#
#
# LIST OF LEAP SECONDS
# NTP timestamp (X parameter) is the number of seconds since 1900.0
#
# MJD: The Modified Julian Day number. MJD = X/86400 + 15020
#
# DTAI: The difference DTAI= TAI-UTC in units of seconds
# It is the quantity to add to UTC to get the time in TAI
#
# Day Month Year : epoch in clear
#
#NTP Time DTAI Day Month Year
#
2272060800 10 # 1 Jan 1972
2287785600 11 # 1 Jul 1972
2303683200 12 # 1 Jan 1973
2335219200 13 # 1 Jan 1974
2366755200 14 # 1 Jan 1975
2398291200 15 # 1 Jan 1976
2429913600 16 # 1 Jan 1977
2461449600 17 # 1 Jan 1978
2492985600 18 # 1 Jan 1979
2524521600 19 # 1 Jan 1980
2571782400 20 # 1 Jul 1981
2603318400 21 # 1 Jul 1982
2634854400 22 # 1 Jul 1983
2698012800 23 # 1 Jul 1985
2776982400 24 # 1 Jan 1988
2840140800 25 # 1 Jan 1990
2871676800 26 # 1 Jan 1991
2918937600 27 # 1 Jul 1992
2950473600 28 # 1 Jul 1993
2982009600 29 # 1 Jul 1994
3029443200 30 # 1 Jan 1996
3076704000 31 # 1 Jul 1997
3124137600 32 # 1 Jan 1999
3345062400 33 # 1 Jan 2006
3439756800 34 # 1 Jan 2009
3550089600 35 # 1 Jul 2012
3644697600 36 # 1 Jul 2015
3692217600 37 # 1 Jan 2017
#
# A hash code has been generated to be able to verify the integrity
# of this file. For more information about using this hash code,
# see the README file in the 'sources' directory.
#
#h 89073fa8 9e913fd7 60559aa5 29d1feee 5b0f6c91
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment