File: windows.compare

package info (click to toggle)
libdate-manip-perl 6.76-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 16,228 kB
  • sloc: perl: 246,208; sh: 54; makefile: 11
file content (146 lines) | stat: -rw-r--r-- 3,315 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/perl
# Copyright (c) 2008-2019 Sullivan Beck.  All rights reserved.
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

###############################################################################
###############################################################################
# This script will check windows timezone information.

my $new = 'windows.new';
require "data.alias.pl";

############################################################################
# MAIN PROGRAM
############################################################################

my %old = %windows_zones;
my %new = _parse($new);

# Find deprecated zones

my @old;
foreach my $key (keys %old) {
   next  if (exists $new{$key});
   push(@old,$key);
}

if (@old) {
   print "The following zones need to be removed:\n";
   foreach my $key (sort @old) {
      print "   $key\n";
      delete $old{$key};
   }
   print "\n";
}

# Find new zones

my @new;
foreach my $key (keys %new) {
   next  if (exists $old{$key});
   push(@new,$key);
}

if (@new) {
   print "The following zones need to be added (check that the zones are in tzdata):\n";
   foreach my $key (sort @new) {
      my $val = $new{$key};
      print "   \"$key\"" . " "x(32-length($key)) . "=> \"$val\",\n";
      delete $new{$key};
   }
   print "\n";
}

# Find changed zones

my @chg;
foreach my $key (keys %old) {
   next  if ($old{$key} eq $new{$key});
   push(@chg,$key);
}

if (@chg) {
   print "The following zones need to be changed (verify in tzdata first):\n";
   foreach my $key (sort @chg) {
      my $val = $new{$key};
      print "   \"$key\"" . " "x(32-length($key)) . "=> \"$val\",\n";
   }
   print "\n";
}

############################################################################
############################################################################

# It's a file of TAB separated lines:
#
#    ALIAS \t TAG \t ZONE_LIST
#
# where ALIAS is the windows time zone name and ZONE_LIST is a space
# separated list of timezones.
#
# ALIAS may appear on multiple lines... use the first, and ZONE_LIST
# may have multiple zones... use the first.
#
sub _parse {
   my($file) = @_;
   my %ret;

   my @lines = `cat $file`;
   chomp(@lines);

   my $n = 0;
   foreach my $line (@lines) {
      $n++;

      my @f = split(/\t/,$line);
      if (@f != 3) {
         warn "ERROR: invalid line: $file[$n]\n" .
              "       $line\n";
      }

      my($alias,$tmp,$zones) = @f;
      next  if (exists $ret{$alias});

      my @tmp = split(/\s+/,$zones);
      my $zone = $tmp[0];

      $ret{$alias} = $zone;
   }

   return %ret;
}

# For CLDR 2.0
# sub _parse {
#    my($file) = @_;
#    my %ret;

#    my @lines = `cat $file`;
#    chomp(@lines);

#    my $n = 0;
#    foreach my $line (@lines) {
#       $n++;

#       if ($line =~ /^\s*(.*?)\s+any\s+(.*?)\s*$/) {
#          $ret{$1} = $2;
#       } else {
#          warn "ERROR: invalid line: $file[$n]\n" .
#               "       $line\n";
#       }
#    }

#    return %ret;
# }

# Local Variables:
# mode: cperl
# indent-tabs-mode: nil
# cperl-indent-level: 3
# cperl-continued-statement-offset: 2
# cperl-continued-brace-offset: 0
# cperl-brace-offset: 0
# cperl-brace-imaginary-offset: 0
# cperl-label-offset: 0
# End: