Browse files

Order the TimeZones.

Switch from a hash to an array and reorder the TZs from West to East.
  • Loading branch information...
1 parent 20faf3a commit 51e8e3b2dc343a09aae4bb2adcb8f826bafd3e88 geraud committed Sep 28, 2010
Showing with 13 additions and 10 deletions.
  1. +13 −10 lib/Bot/BasicBot/Pluggable/Module/Clock.pm
View
23 lib/Bot/BasicBot/Pluggable/Module/Clock.pm
@@ -7,13 +7,16 @@ use base 'Bot::BasicBot::Pluggable::Module';
our $VERSION = 0.01;
use POSIX qw{ strftime tzset };
-my %tz = (
- SYD => 'Australia/Sydney',
- UTC => 'UTC',
- LAX => 'America/Los_Angeles',
- NYC => 'America/New_York',
- MAD => 'Europe/Madrid',
- TOK => 'Asia/Tokyo',
+# Sort the Time Zones from West to East.
+my @time_zones = (
+ ['LAX', 'America/Los_Angeles'],
+ ['CHI', 'America/Chicago'],
+ ['NYC', 'America/New_York'],
+ ['UTC', 'UTC'],
+ ['LON', 'Europe/London'],
+ ['BER', 'Europe/Berlin'],
+ ['TOK', 'Asia/Tokyo'],
+ ['SYD', 'Australia/Sydney'],
);
sub told {
@@ -22,9 +25,9 @@ sub told {
( my $msg_body = $message->{'body'} ) =~ s/^\s+//;
if ($msg_body eq 'clock?') {
my @dates;
- for my $name (sort keys %tz) {
- local $ENV{TZ} = $tz{$name};
- push @dates, strftime("$name: %a, %H:%M %Z", localtime());
+ for my $tz (@time_zones) {
+ local $ENV{TZ} = $tz->[1];
+ push @dates, strftime("$tz->[0]: %a, %H:%M %Z", localtime());
}
$self->reply($message, $message->{who} . ': ' . join(' / ', @dates));
}

0 comments on commit 51e8e3b

Please sign in to comment.