Question

Locked

Perl

By jayaprakashk ·
Hi,
Below perl code not returning TimeZone in given order, please suggest solution how to make this code to return time zone in given order.

sub GetTimeZoneList
{
my $self = shift;
my ($piArraysList,$iDefault) = @_;
my %TimeZoneKeyValue = ('(GMT-12:00) International Date Line West','GMT-12:00',
'(GMT-11:00) Midway Island, Samoa','Pacific/Samoa',
'(GMT-10:00) Hawaii','US/Hawaii',
'(GMT-09:00) Alaska','US/Alaska',
'(GMT-08:00) Pacific Time (US and Canada); Tijuana','Canada/Pacific',
'(GMT-07:00) Mountain Time (US and Canada)','Canada/Mountain',
'(GMT-07:00) Chihuahua, La Paz, Mazatlan','America/Chihuahua',
'(GMT-07:00) Arizona','US/Arizona',
'(GMT-06:00) Saskatchewan','Canada/Saskatchewan',
'(GMT-06:00) Guadalajara, Mexico City, Monterrey','America/Monterrey',
'(GMT-06:00) Central Time (US and Canada)','Canada/Central',
'(GMT-06:00) Central America','US/Central',
'(GMT-05:00) Indiana (East)','US/East-Indiana',
'(GMT-05:00) Eastern Time (US and Canada)','US/Eastern',
'(GMT-05:00) Bogota, Lima, Quito','America/Bogota',
'(GMT-04:00) Santiago','America/Santiago',
'(GMT-04:00) Manaus','America/Manaus',
'(GMT-04:00) Caracas, La Paz','America/Caracas',
'(GMT-04:00) Atlantic Time (Canada)','Canada/Atlantic',
'(GMT-03:30) Newfoundland and Labrador','Canada/Newfoundland',
'(GMT-03:00) Greenland','America/Godthab',
'(GMT-03:00) Buenos Aires, Georgetown','America/Buenos_Aires',
'(GMT-03:00) Brasilia','Brazil/East',
'(GMT-02:00) Mid-Atlantic','Atlantic/South_Georgia',
'(GMT-01:00) Cape Verde Islands','Atlantic/Cape_Verde',
'(GMT-01:00) Azores','Atlantic/Azores',
'(GMT) Casablanca, Monrovia','Africa/Casablanca',
'(GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London','Europe/London',
'(GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna','Europe/Amsterdam',
'(GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague','Europe/Belgrade',
'(GMT+01:00) Brussels, Copenhagen, Madrid, Paris','Europe/Brussels',
'(GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb','Europe/Sarajevo',
'(GMT+01:00) West Central Africa','Africa/Lagos',
'(GMT+02:00) Athens, Bucharest, Istanbul','Europe/Athens',
'(GMT+02:00) Cairo','Africa/Cairo',
'(GMT+02:00) Harare, Pretoria','Africa/Harare',
'(GMT+02:00) Helsinki, Kiev, Riga, Sofia, Tallinn, Vilnius','Europe/Helsinki',
'(GMT+02:00) Jerusalem','Asia/Jerusalem',
'(GMT+02:00) Minsk','Europe/Minsk',
'(GMT+02:00) Windhoek','Africa/Windhoek',
'(GMT+03:00) Baghdad','Asia/Baghdad',
'(GMT+03:00) Kuwait, Riyadh','Asia/Kuwait',
'(GMT+03:00) Moscow, St. Petersburg, Volgograd','Europe/Moscow',
'(GMT+03:00) Nairobi','Africa/Nairobi',
'(GMT+03:30) Tehran','Asia/Tehran',
'(GMT+04:00) Abu Dhabi, Muscat','Asia/Muscat',
'(GMT+04:00) Baku','Asia/Baku',
'(GMT+04:00) Tblisi','Asia/Tbilisi',
'(GMT+04:00) Yerevan','Asia/Yerevan',
'(GMT+04:30) Kabul','Asia/Kabul',
'(GMT+05:00) Ekaterinburg','Asia/Yekaterinburg',
'(GMT+05:00) Islamabad, Karachi, Tashkent','Asia/Karachi',
'(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi','Asia/Calcutta',
'(GMT+05:45) Kathmandu','Asia/Katmandu',
'(GMT+06:00) Almaty, Novosibirsk','Asia/Almaty',
'(GMT+06:00) Astana, Dhaka','Asia/Dacca',
'(GMT+06:00) Sri Jayawardenepura','Asia/Jayapura',
'(GMT+06:30) Yangon (Rangoon)','Asia/Rangoon',
'(GMT+07:00) Bangkok, Hanoi, Jakarta','Asia/Bangkok',
'(GMT+07:00) Krasnoyarsk','Asia/Krasnoyarsk',
'(GMT+08:00) Beijing, Chongqing, Hong Kong SAR, Urumqi','Asia/Hong_Kong',
'(GMT+08:00) Irkutsk, Ulaanbaatar','Asia/Irkutsk',
'(GMT+08:00) Kuala Lumpur, Singapore','Asia/Kuala_Lumpur',
'(GMT+08:00) Perth','Australia/Perth',
'(GMT+08:00) Taipei','Asia/Taipei',
'(GMT+09:00) Osaka, Sapporo, Tokyo','Asia/Tokyo',
'(GMT+09:00) Seoul','Asia/Seoul',
'(GMT+09:00) Yakutsk','Asia/Yakutsk',
'(GMT+09:30) Adelaide','Australia/Adelaide',
'(GMT+09:30) Darwin','Australia/Darwin',
'(GMT+10:00) Brisbane','Australia/Brisbane',
'(GMT+10:00) Canberra, Melbourne, Sydney','Australia/Canberra',
'(GMT+10:00) Guam, Port Moresby','Pacific/Guam',
'(GMT+10:00) Hobart','Australia/Hobart',
'(GMT+10:00) Vladivostok','Asia/Vladivostok',
'(GMT+11:00) Magadan, Solomon Islands, New Caledonia','Asia/Magadan',
'(GMT+12:00) Auckland, Wellington','Pacific/Auckland',
'(GMT+12:00) Fiji Islands, Kamchatka, Marshall Islands','Pacific/Fiji',
'(GMT+13:00) Nuku alofa','Pacific/Tongatapu');

my @DstObserveValues = ('N','N');


my $bDefaultFound = 0;
my @iArraysTimeZoneKey = (); #list of TimeZone name displayed in screen.
my @iArraysTimeZoneValue = (); #list of ids for corresponding timezone.
my @iArraysTimeZoneSel = (); #list of Selection flags
my @iArraysDSTObserveVal = (); #list of DST Observed Value
my @iArraysID = ();


for my $key ( keys %TimeZoneKeyValue )
{
push(@iArraysID,$key);
my $value = $TimeZoneKeyValue{$key};
#print "$key => $value\n";
push(@iArraysTimeZoneKey,$key);
push(@iArraysTimeZoneValue,$value);
# print STDERR " iDefault : $iDefault -- Key -- $key --- Value -- $value\n ";


if (defined $iDefault && $iDefault eq $value )
{
push(@iArraysTimeZoneSel, 'selected');
$bDefaultFound = 1;
}else{
push(@iArraysTimeZoneSel, '');
}
}

my $iDstObserveValue;
for $iDstObserveValue (@DstObserveValues)
{
push(@iArraysDSTObserveVal,$iDstObserveValue);
}

# If TimeZone not selected default value set

if (defined($iDefault) && $bDefaultFound == 0)
{
unshift(@iArraysTimeZoneKey,$iDefault);
unshift(@iArraysTimeZoneValue,$iDefault);
unshift(@iArraysTimeZoneSel,'selected');
}
else{
# unshift(@iArraysTimeZoneKey,'');
# unshift(@iArraysTimeZoneValue,'');
# unshift(@iArraysTimeZoneSel,'');
}
$piArraysList->{TIMEZONE_VAL} = \@iArraysTimeZoneValue;
$piArraysList->{TIMEZONE_DESC} = \@iArraysTimeZoneKey;
$piArraysList->{TIMEZONE_SELECTED} = \@iArraysTimeZoneSel;
$piArraysList->{TIMEZONE_DSTVAL} = \@iArraysDSTObserveVal;
$piArraysList->{TIMEZONE_CNT} = $#iArraysID + 1;

}

This conversation is currently closed to new comments.

2 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Seem to be missing critical piece of info there matey

by Tony Hopkinson In reply to Perl

As in total lack on mention what the given order is and what order you are getting....

Back to Networks Forum
2 total posts (Page 1 of 1)  

Related Discussions

Related Forums