|
|
Create aliases for quick timezone checks
Thanks for the original posting and Perl solution. I made the perl script a little more Perlish. The first reason I changed was when I did "itime hongkong", I got something like "zoneinfo/hongkong blah ...", which wasn't quite pretty. It happens when timezone data files are right under /usr/share/zonefile, such as Turkey, Poland, etc. This new version prints only city name and its local time. The second change was now it can accept case-insensitive city name. In other words, you get the same result whether you type "seoul" or "Seoul".
#!/usr/bin/perl -w
use strict;
use File::Find;
use File::Basename;
my $zoneDir="/usr/share/zoneinfo";
my $city = shift || die "Usage: itime city\n";
find(\&wanted, $zoneDir);
sub wanted {
if ( -f $_ && $_ =~ /$city/i ) {
$ENV{'TZ'}=basename($File::Find::dir)."/$_";
my $time=localtime();
print "$_ $time\n";
}
}
Create aliases for quick timezone checks
dang... geeklog ate up backslashes when I posted as HTML, though it was okay when I previewed it. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.05 seconds |
|