tzdata: update to 2018g
[unleashed.git] / contrib / tzdata / zoneinfo2tdf.pl
blobc8c5591afee0c4deac00c1e411c90ebc1f6b4ce1
1 #! /usr/bin/perl -w
2 # Summarize .zi input in a .zi-like format.
4 # Courtesy Ken Pizzini.
6 use strict;
8 #This file released to the public domain.
10 # Note: error checking is poor; trust the output only if the input
11 # has been checked by zic.
13 my $contZone = '';
14 while (<>) {
15 my $origline = $_;
16 my @fields = ();
17 while (s/^\s*((?:"[^"]*"|[^\s#])+)//) {
18 push @fields, $1;
20 next unless @fields;
22 my $type = lc($fields[0]);
23 if ($contZone) {
24 @fields >= 3 or warn "bad continuation line";
25 unshift @fields, '+', $contZone;
26 $type = 'zone';
29 $contZone = '';
30 if ($type eq 'zone') {
31 # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL]
32 my $nfields = @fields;
33 $nfields >= 5 or warn "bad zone line";
34 if ($nfields > 6) {
35 #this splice is optional, depending on one's preference
36 #(one big date-time field, or componentized date and time):
37 splice(@fields, 5, $nfields-5, "@fields[5..$nfields-1]");
39 $contZone = $fields[1] if @fields > 5;
40 } elsif ($type eq 'rule') {
41 # Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
42 @fields == 10 or warn "bad rule line";
43 } elsif ($type eq 'link') {
44 # Link TARGET LINK-NAME
45 @fields == 3 or warn "bad link line";
46 } elsif ($type eq 'leap') {
47 # Leap YEAR MONTH DAY HH:MM:SS CORR R/S
48 @fields == 7 or warn "bad leap line";
49 } else {
50 warn "Fubar at input line $.: $origline";
52 print join("\t", @fields), "\n";