[erlang-patches] R13A test case example: how to test leap-second code on FreeBSD

Kenji Rikitake <>
Tue Apr 7 15:33:41 CEST 2009

I found out a part of my patch was incorporated in
R13A erts/emulator/beam/erl_time_sup.c, and I saw
a question in the comment that there was no test case
for checking whether the TAI (leap second) support
really works.

Here is a piece of code for testing on FreeBSD.
(see /usr/src/share/zoneinfo/Makefile for the details)
I think this will work on 7.x as well as 6.x.

For testing a TAI-based clock on FreeBSD
(with leap second support)
perform the following script on root
then the zone file will include the leap seconds:

# -- begin --
cd /usr/src/share/zoneinfo
make -DLEAPSECONDS clean install
# CAUTION: set to your local timezone
cp /usr/share/zoneinfo/Europe/Stockholm /etc/localtime
# -- end --

For putting back into non-leap-second clock on FreeBSD,
perform the following script on root:

# -- begin --
cd /usr/src/share/zoneinfo
make clean install
# CAUTION: set to your local timezone
cp /usr/share/zoneinfo/Europe/Stockholm /etc/localtime
# -- end --

These scripts will change the timezone definition *system-wide*.

I hope this helps and I appreciate you put in the code into R13A.

Kenji Rikitake

In the message <>
dated Fri, Oct 17, 2008 at 10:53:37AM +0200,
Bjorn Gustavsson <> writes:
> > A patch to correct erlang:universaltime_to_localtime/1
> > for FreeBSD running leap-second-enabled timezone
> > by Kenji Rikitake <>
> > 14-SEP-2008
> >
> > * Summary
> >
> > This patch fixes the time calculation problem of
> > FreeBSD 6.x and 7.x, which has the internal leap-second
> > correction enabled.
> > This patch is tested with Erlang/OTP R12B-4 source distribution.
> >
> We will probably add the patch to R12B-5 with slight modifications.
> /Bjorn

More information about the erlang-patches mailing list