• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/perl
2#
3# Copyright (C) 2016 and later: Unicode, Inc. and others.
4# License & terms of use: http://www.unicode.org/copyright.html
5#   Copyright (C) 2007-2007, International Business Machines
6#   Corporation and others.  All Rights Reserved.
7#
8
9if ($ARGV[0] eq '-h' || $ARGV[0] eq '--help') {
10	print "Usage: tzone [year month day hour minute]\n";
11	exit(0);
12}
13
14my $LIBRARY = '../../lib';
15
16my @TZONE_RAW = `locate zoneinfo | grep '^/usr/share/zoneinfo/' | grep -v 'tab\$' | grep -v '/right/' | grep -v '/posix/' | grep -v '/posixrules\$' | grep -v '/Factory\$'`;
17my @TZONE;
18my $index = 0;
19my $USECURRENT = 0;
20my $year = 0;
21my $month = 0;
22my $day = 0;
23my $hour = 0;
24my $minute = 0;
25
26
27if (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
36foreach 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
48print "The following time zones had wrong results.\n";
49
50foreach 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
64print "\nThe number of time zones with wrong results:  $count out of $index\n";
65
66print("\n\nGood Bye!\n");
67exit(0);
68