Quick actions

cmd+k|ctrl+k

Navigation

Languages

count working days

Snippet info

Language

Perl

Visibility

public

Author

grtodd

Created

2017-03-13T13:15:30Z

Updated

2017-03-13T13:15:30Z

use 5.24.0;
use Time::Piece;
use Time::Seconds;

my $start = '2017-01-01' ;
my $end = '2017-05-10' ;
my $format = "%Y-%m-%d" ;
my $ndays = abs (Time::Piece->strptime($start, $format) - Time::Piece->strptime($end, $format))->days ;

my $t = Time::Piece->strptime($start, $format) ; 

say $t->day;
say $ndays;

my $workingdays=0;

for (0..$ndays){
$t += ONE_DAY ;
$workingdays++ unless ($t->day =~ /Sun|Sat/);
}

print $workingdays;
INFO