Time span in hours
This commit is contained in:
parent
872e29b9bc
commit
c523eb5d3b
1 changed files with 28 additions and 0 deletions
28
time-span-in-hours.plx
Executable file
28
time-span-in-hours.plx
Executable file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Getopt::Long;
|
||||
|
||||
sub TimeCalc($$) {
|
||||
my($date, $start) = @_;
|
||||
my $finish = $start;
|
||||
use Date::Manip;
|
||||
$start =~ s/^\s*([^\-]+)\-.*$/$1/;
|
||||
$finish =~ s/^.*\-([^\-]+)\s*$/$1/;
|
||||
$start = ParseDate("$date $start");
|
||||
$finish = ParseDate("$date $finish");
|
||||
return Delta_Format(DateCalc($start, $finish), 5, '%ht');
|
||||
}
|
||||
my $input;
|
||||
if (@ARGV == 0) {
|
||||
$input = <STDIN>;
|
||||
chomp $input;
|
||||
} elsif (@ARGV == 1) {
|
||||
$input = $ARGV[0];
|
||||
} else {
|
||||
die "oneargor noarg";
|
||||
}
|
||||
|
||||
print TimeCalc('today', $input), "\n";
|
Loading…
Add table
Reference in a new issue