in reply to Calculate seconds between dates

Hello packetstormer,

An alternative solution to your problem could be to the use of Date::Manip module.

The module is very very powerful and with simple use of ""business" you can choose to only calculate the days that are business days and not holidays/weekends.

Business day for the module is considered 08:00am - 05:00pm (9 hours / 1 hour lunch). Sample of code below:

#!/usr/bin/perl use strict; use warnings; use Date::Manip; my $date_1 = "November 24 2017 4:59pm"; my $date_2 = "November 27 2017 08:01am"; my $sec = Delta_Format(DateCalc($date_1, $date_2, "business"), 0, "%st +"); printf "diff secs: %d\n", $sec; __END__ $ perl sample.pl diff secs: 120

More information regarding the functions you can find here Date::Manip::DM5. If for any reason you want to change the hours/days you can do it through Date::Manip::Config/BUSINESS CONFIGURATION VARIABLES.

Update: Adding the Mode "business" explanation. The third parameter that you can add on the DateCalc function is $mode. This parameter when you do date calculations can take 6 different options. Sample from the documentation:

exact : an exact, non-business calculation semi : a semi-exact, non-business calculation approx : an approximate, non-business calculation business : an exact, business calculation bsemi : a semi-exact, business calculation bapprox : an approximate, business calculation

For more information you can read the official documentation Date::Manip::Calc/MODE.

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!