Like any other piece of software (and information generally), 
leapsunpack comes with NO WARRANTY.

This program is designed to augment D. J. Bernstein's libtai package,
available at http://cr.yp.to/libtai/libtai-0.60.tar.gz

=======
Compile
=======

The leapsunpack program can be compiled by running make from the command
line.

  $ make

=================
Check correctness
=================

Test the correctness of leapsunpack against D. J. Bernstein's provided
leapsecs.txt table, available at http://cr.yp.to/libtai/leapsecs.txt

1. Strip the known correct leapsecs.txt file of blank lines and
comments:

  $ sed '/^$/d;/^#/d' leapsecs.txt > leaps.original

2. Now run leapsunpack and compare the two:

  $ dnstxt leap.yp.to | leapsunpack | cmp - leaps.original

The dnstxt program is part of the djbdns-1.05 package, available at
http://cr.yp.to/djbdns/djbdns-1.05.tar.gz

If you do not have djbdns-1.05, you may also use dig or nslookup.

  $ dig leap.yp.to txt

or

  $ nslookup -q=txt leap.yp.to

Be aware that both dig and nslookup return additional lines of
formatting other than the TXT record that leapsunpack parses. If you use
either dig or nslookup, you will need to manually extract the
leap table.  It is the numerical string beginning with "822222". Put
this string into a file, and run it through leapsunpack:

  $ leapsunpack < file

Alternatively, leapsunpack version 0.04 and up can query leap.bze.ro by
itself using the "-a" flag. This will automatically generate the
leap second table on any system that can make DNS queries. leapsunpack
will only contact leap.bze.ro. If you wish to obtain the compressed
leap second table from another location, you cannot use the "-a" flag.

  $ leapsunpack -a

=====
Usage
=====

To create or update /etc/leapsecs.dat, perform the following:

  $ dnstxt leap.yp.to | leapsunpack | leapsecs > leapsecs.dat.new
  $ sudo mv -f leapsecs.dat.new /etc/leapsecs.dat

or have it contact leap.yp.to directly

  $ leapsunpack -a | leapsecs > leapsecs.dat.new
  $ sudo mv -f leapsecs.dat.new /etc/leapsecs.dat

Alternatively, leapsunpack version 0.05 and up contains a very slightly
modified version of D. J. Bernstein's leapsecs program in addition to a
simple shell script that will automatically create or update 
/etc/leapsecs.dat for you. If necessary, specify a different location
or name for the leap second table. The default is /etc/leapsecs.dat.

  $ leapsinstall

or

  $ leapsinstall /path/to/myleapsecs.dat

=================================
Making Time Zones the "right" Way
=================================

If you are on an operating system without a proper
/usr/share/zoneinfo/right directory, you can create your own with the
leaps2zic program. leaps2zic takes an unpacked list of leap seconds and
converts it to a format that can be understood by zic when building
time zone files. Do not use leaps2zic with leapsecs.dat.

Fetch an unpacked list of leap seconds if you do not have one already:

  $ leapsunpack -a > leapsecs.txt

This list will have the format of "+YYYY-MM-DD" for each day in which a
leap second is added, one per line.

  $ head leapsecs.txt
  +1972-06-30
  +1972-12-31
  +1973-12-31
  +1974-12-31
  +1975-12-31
  +1976-12-31
  +1977-12-31
  +1978-12-31
  +1979-12-31
  +1981-06-30

Create a zic-compatible "leapsecs.zic" file from leapsecs.txt:

  $ leaps2zic /etc/leapsecs.txt > leapsecs.zic

  $ head leapsecs.zic
  Leap    1972    Jun     30      23:59:60        +       S
  Leap    1972    Dec     31      23:59:60        +       S
  Leap    1973    Dec     31      23:59:60        +       S
  Leap    1974    Dec     31      23:59:60        +       S
  Leap    1975    Dec     31      23:59:60        +       S
  Leap    1976    Dec     31      23:59:60        +       S
  Leap    1977    Dec     31      23:59:60        +       S
  Leap    1978    Dec     31      23:59:60        +       S
  Leap    1979    Dec     31      23:59:60        +       S
  Leap    1981    Jun     30      23:59:60        +       S

Use this file to create a correct time zone file. For example, to make a
new UTC time zone on OpenBSD 6.7:

  $ echo "Zone UTC 0 - UTC" > etcetera

  $ /usr/sbin/zic -y yearistype.sh -d . -L leapsecs.zic etcetera

This willl create a new "UTC" time zone file in the current directory.

The yearistype.sh script can be found in the OpenBSD source code
repository, or downloaded from:

<URL:https://raw.githubusercontent.com/openbsd/src/master/share/zoneinfo/datfiles/yearistype.sh>

Create /usr/share/zoneinfo/right if it does not exist. Move the new
UTC file into /usr/share/zoneinfo/right and update your /etc/localtime
symbolic link. Make sure you've created /etc/leapsecs.dat as previously
described above.

That's it! To report success:

  $ (echo 'First M. Last'; cat `cat SYSDEPS`) | mail toby-qst@su.bze.ro

Replace First M. Last with your name.
