1#!/usr/bin/perl 2# 3# Copyright (C) 2007-2007, International Business Machines 4# Corporation and others. All Rights Reserved. 5# 6 7if ($ARGV[0] eq '-h' || $ARGV[0] eq '--help') { 8 print "Usage: tzone [year month day hour minute]\n"; 9 exit(0); 10} 11 12my $LIBRARY = '../../lib'; 13 14my @TZONE_RAW = `locate zoneinfo | grep '^/usr/share/zoneinfo/' | grep -v 'tab\$' | grep -v '/right/' | grep -v '/posix/' | grep -v '/posixrules\$' | grep -v '/Factory\$'`; 15my @TZONE; 16my $index = 0; 17my $USECURRENT = 0; 18my $year = 0; 19my $month = 0; 20my $day = 0; 21my $hour = 0; 22my $minute = 0; 23 24 25if (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 34foreach 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 46print "The following time zones had wrong results.\n"; 47 48foreach 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 62print "\nThe number of time zones with wrong results: $count out of $index\n"; 63 64print("\n\nGood Bye!\n"); 65exit(0); 66