DateTime-Lite

 view release on metacpan or  search on metacpan

scripts/build_tz_database.pl  view on Meta::CPAN

#   compiles the Olson source files with zic(1), then reads the resulting
#   TZif binary files (RFC 8536). Downloaded tarballs are cached under
#   ~/.cache/dtl-tzdata/ to avoid redundant downloads.
#
#   Fallback mode (--zoneinfo): reads TZif files from a local zoneinfo
#   directory instead of downloading. Useful when IANA is not reachable.
#
# REQUIREMENTS
#   Always:       zic(1), Perl 5.10.1+, DBD::SQLite >= 1.27, DBI >= 1.611
#   IANA mode:    HTTP::Promise or Net::FTP depending on --proto (default to 'http')
#   Recommended:  gpg(1) for signature verification
#   Optional:     rdfind(1), symlinks(1) for zoneinfo deduplication
#
# SEE ALSO
#   Repository on Github: <https://github.com/eggert/tz>
##----------------------------------------------------------------------------
use v5.10.1;
use strict;
use warnings;
use Config;
use Data::Pretty qw( dump );

scripts/build_tz_database.pl  view on Meta::CPAN

    if( $basename =~ /tzdata(\d{4}[a-z]+)\.tar\.gz/ )
    {
        return( $1 );
    }

    die( "Cannot determine tzdata version from '$tarball'.\n" );
}

# _verify_signature( $tarball )
# Verifies the GPG signature $tarball.asc against $tarball.
# Non-fatal if gpg is absent or the key cannot be fetched.
sub _verify_signature
{
    my $tarball = shift( @_ );
    my $asc     = file( "$tarball.asc" );
    _message( 2, "Verifying tarball signature with <green>$asc</>" );

    my $gpg = _has_tool('gpg');
    unless( $gpg )
    {
        warn( "  gpg not found; skipping signature verification.\n" );
        return;
    }
    unless( $asc->exists )
    {
        warn( "  Signature file '$asc' not found; skipping verification.\n" );
        return;
    }

    # Try to ensure the IANA signing key is available.
    # Paul Eggert's current key: ED97E90E62AA7E34
    my $key_id = 'ED97E90E62AA7E34';
    unless( qx( gpg --list-keys "$key_id" 2>/dev/null ) =~ /$key_id/i )
    {
        _message( 1, "  Importing IANA signing key $key_id..." );
        system( $gpg,
            '--keyserver', 'keys.openpgp.org',
            '--recv-keys', $key_id
        ) == 0 || warn( "Warning only: error calling $gpg to import IANA public key: exit ", ( $? >> 8 ) );
        # Non-fatal: key servers may be unreachable
    }

    _message( 1, "  Verifying GPG signature with: $gpg --verify $asc $tarball" );
    if( system( $gpg, '--verify', $asc, $tarball ) )
    {
        warn( "  GPG signature verification FAILED for '$tarball'.\n"
            . "  Proceeding; verify manually if this concerns you.\n" );
    }
    else
    {
        _message( 1, "  Signature OK." );
    }
}

scripts/build_tz_database.pl  view on Meta::CPAN

Print one line per timezone as it is processed.

=back

=head1 REQUIREMENTS

Always required: C<zic(1)> (from the C<tzdata> or C<tz-utils> system package), L<DBI>, L<DBD::SQLite> >= 1.27.

For primary mode: C<curl(1)> or C<wget(1)>.

Recommended: C<gpg(1)> for signature verification.

Optional (non-fatal if absent): C<rdfind(1)> for deduplication, C<symlinks(1)> for relative symlink conversion.

=head1 EPOCH CONVERSION

TZif transition times are stored as seconds since the Unix epoch (1970-01-01T00:00:00 UTC). L<DateTime> uses seconds since the Rata Die epoch (0001-01-01T00:00:00). The constant C<UNIX_TO_RD = 62_135_683_200> converts between them.

=head1 AUTHOR

Jacques Deguest E<lt>F<jack@deguest.jp>E<gt>



( run in 0.572 second using v1.01-cache-2.11-cpan-e1769b4cff6 )