Created
March 2, 2012 16:03
-
-
Save tron1point0/1959334 to your computer and use it in GitHub Desktop.
You type stuff as arguments, it gives you the local time
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.14; | |
use warnings; | |
use Time::Format qw(time_format); | |
use Time::ParseDate; | |
die <<END if $ARGV[0] && $ARGV[0] =~ m/-h(?:elp)?/; | |
$0: Fuzzy time conversion to localtime | |
Usage: | |
$0 time [--] [format] | |
`time` can be any string that Time::ParseDate accepts | |
`format` can be any string that Time::Format::time_format accepts | |
END | |
my @time; | |
push @time, shift(@ARGV) while $ARGV[0] && $ARGV[0] ne '--'; | |
my $timestr = join ' ',@time; | |
my $time = parsedate($timestr); | |
shift(@ARGV) if defined $ARGV[0] && $ARGV[0] eq '--'; | |
my $formatstr = join(' ',@ARGV) || 'yyyy-mm{on}-dd hh:mm{in}:ss tz'; | |
say time_format $formatstr, $time; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment