NAME

leap_seconds_header.pl - Generate leap_seconds.h for DateTime::Lite XS

SYNOPSIS

perl scripts/leap_seconds_header.pl [input] [output]

# Using system leap-seconds.list (default):
perl scripts/leap_seconds_header.pl

# Explicit paths:
perl scripts/leap_seconds_header.pl /usr/share/zoneinfo/leap-seconds.list leap_seconds.h

DESCRIPTION

Reads the IERS leap-seconds.list file and generates a C header defining three macros:

SET_LEAP_SECONDS(utc_rd, leaps)

Sets leaps to the count of leap seconds accumulated since 1972 for the given Rata Die day utc_rd.

SET_EXTRA_SECONDS(utc_rd, es)

Sets es to +1 if utc_rd is a leap second day, 0 otherwise.

SET_DAY_LENGTH(utc_rd, dl)

Sets dl to 86400 or 86401 depending on whether utc_rd is a leap second day.

RATA DIE CONVENTION

Rata Die day 1 = 0001-01-01. Day 719163 = 1970-01-01 (Unix epoch).

LEAP-SECONDS.LIST FORMAT

Each data line contains an NTP timestamp (seconds since 1900-01-01) and the cumulative TAI-UTC count effective from that timestamp. The baseline before the first 1972 leap second is 10. Accumulated since 1972 = TAI-UTC - 10.

The RD stored for each entry is the first day of the new count (the day after 23:59:60).

AUTHOR

Jacques Deguest <jack@deguest.jp>

COPYRIGHT & LICENSE

Copyright(c) 2026 DEGUEST Pte. Ltd.

All rights reserved

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.