root/misc/worlddate

Revision 2105 (checked in by miyagawa, 13 years ago)

add coloring

  • Property svn:executable set to *
Line 
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4 use DateTime;
5 use DateTime::TimeZone;
6 use Term::ANSIColor;
7
8 my @tz = (
9     'UTC',
10     'Pacific/Honolulu',
11     [ 'America/Los_Angeles' ],
12     'America/Chicago',
13     'America/New_York',
14     'Europe/London',
15     'Europe/Paris',
16     'Europe/Berlin',
17     'Europe/Rome',
18     'Europe/Madrid',
19     'Asia/Jakarta',
20     'Asia/Bangkok',
21     'Asia/Taipei',
22     'Asia/Shanghai',
23     'Asia/Hong_Kong',
24     [ 'Asia/Tokyo' ],
25     'Australia/Sydney',
26     'Pacific/Auckland',
27 );
28
29 my $dt = DateTime->now;
30 for my $tz (@tz) {
31     my $color;
32     if (ref $tz) {
33         $tz = $tz->[0];
34         $color = 1;
35     }
36     $dt->set_time_zone($tz);
37     print color 'yellow' if $color;
38     print $dt->strftime("%Y/%m/%d (%a) %H:%M:%S "), $dt->time_zone->name, ($dt->is_dst ? '*' : ''), "\n";
39     print color 'reset' if $color;
40 }
Note: See TracBrowser for help on using the browser.