From c523eb5d3b936554f050baf98e410753ea8eb6fd Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Fri, 1 Mar 2024 05:25:05 -0800 Subject: [PATCH] Time span in hours --- time-span-in-hours.plx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 time-span-in-hours.plx diff --git a/time-span-in-hours.plx b/time-span-in-hours.plx new file mode 100755 index 0000000..83276a6 --- /dev/null +++ b/time-span-in-hours.plx @@ -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 = ; + chomp $input; +} elsif (@ARGV == 1) { + $input = $ARGV[0]; +} else { + die "oneargor noarg"; +} + +print TimeCalc('today', $input), "\n";