root/misc/worlddate

Revision 2952 (checked in by miyagawa, 9 years ago)

misc

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