freeswitch/scripts/perl/timezones/build-zonedata.pl
Douglas Vought 07f192ca03
[contrib/timezone-gen] Fix timezone gen (#2215)
* [contrib/timezone-gen] Move timezone-gen.pl to own folder

* [contrib/timezone-gen] Add fixTzstr

* [contrib/timezone-gen] Add tests and zone data getter
 - tests.pl can be used to verify that the generated timezone conf
   will produce the correct datetimes by testing them against
   what the system's `date` says
 - build-zonedata.pl will download the latest tzdb data and build
   the posix timezone data files. It only builds what is needed
   rather than adding extraneous "right/" and "posix/" timezones.
   FreeSWITCH doesn't seem to be able to use the "right/"
   timezone files.
 - data/ is where the various files needed to generate the
   timezones gets stored
2023-09-05 23:11:01 +03:00

28 lines
897 B
Perl
Executable File

#!/usr/bin/perl
use strict;
use warnings;
my $remote_version = `wget --quiet https://data.iana.org/time-zones/tzdb/version --output-document -` =~ s/\n//r;
my $local_version;
if ( open my $in, "<data/version" ) {
$local_version = do { local $/; <$in> };
close $in;
}
my $up_to_date = defined($local_version) && $local_version eq $remote_version;
if ( ! $up_to_date ) {
open my $out, ">data/version";
print $out $remote_version;
close $out;
}
$local_version = $remote_version;
`wget --quiet --timestamping --directory-prefix=data https://data.iana.org/time-zones/tzdb-latest.tar.lz`;
`tar --extract --file=data/tzdb-latest.tar.lz --directory=data`;
`make DESTDIR=../ TZDIR=zones-$local_version --directory=data/tzdb-$local_version posix_only`;
print("Yay. Now you can run\n ./timezone-gen.pl --base=data/zones-$local_version --output=timezones-$local_version.conf.xml")