]>
Commit | Line | Data |
---|---|---|
46f4442e A |
1 | #!/usr/bin/perl |
2 | # | |
f3c0d7a5 A |
3 | # Copyright (C) 2016 and later: Unicode, Inc. and others. |
4 | # License & terms of use: http://www.unicode.org/copyright.html | |
46f4442e A |
5 | # Copyright (C) 2007-2007, International Business Machines |
6 | # Corporation and others. All Rights Reserved. | |
7 | # | |
8 | ||
9 | if ($ARGV[0] eq '-h' || $ARGV[0] eq '--help') { | |
10 | print "Usage: tzone [year month day hour minute]\n"; | |
11 | exit(0); | |
12 | } | |
13 | ||
14 | my $LIBRARY = '../../lib'; | |
15 | ||
16 | my @TZONE_RAW = `locate zoneinfo | grep '^/usr/share/zoneinfo/' | grep -v 'tab\$' | grep -v '/right/' | grep -v '/posix/' | grep -v '/posixrules\$' | grep -v '/Factory\$'`; | |
17 | my @TZONE; | |
18 | my $index = 0; | |
19 | my $USECURRENT = 0; | |
20 | my $year = 0; | |
21 | my $month = 0; | |
22 | my $day = 0; | |
23 | my $hour = 0; | |
24 | my $minute = 0; | |
25 | ||
26 | ||
27 | if (scalar(@ARGV) == 5) { | |
28 | ($year, $month, $day, $hour, $minute) = @ARGV; | |
29 | print "The date we are using is: $month-$day-$year $hour:$minute.\n"; | |
30 | } else { | |
31 | print "We are using the current date.\n"; | |
32 | $USECURRENT = 1; | |
33 | } | |
34 | ||
35 | #filter out the time zones | |
36 | foreach my $tzone (@TZONE_RAW) { | |
37 | chomp($tzone); | |
38 | if (-e $tzone) { | |
39 | $TZONE[$index] = substr($tzone, 20); | |
40 | $index++; | |
41 | } | |
42 | } | |
43 | ||
44 | #go through each timezone and test | |
45 | $count = 0; | |
46 | $ENV{'LD_LIBRARY_PATH'} = $LIBRARY; | |
47 | ||
48 | print "The following time zones had wrong results.\n"; | |
49 | ||
50 | foreach my $tzone (@TZONE) { | |
51 | #set system time zone | |
52 | $ENV{'TZ'} = "$tzone"; | |
53 | ||
54 | my @result = `./tzdate $year $month $day $hour $minute $USECURRENT`; | |
55 | ||
56 | #if the result is wrong print the time zone information to a log file | |
57 | if (scalar(@result) > 0) { | |
58 | print "\nTIME ZONE: $tzone\n"; | |
59 | print "@result\n"; | |
60 | $count++; | |
61 | } | |
62 | } | |
63 | ||
64 | print "\nThe number of time zones with wrong results: $count out of $index\n"; | |
65 | ||
66 | print("\n\nGood Bye!\n"); | |
67 | exit(0); |