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