Hi, I want a little help with the plugin calc.I have to find the difference between two dates but excluding the working days and holidays, "Saturday and Sunday" and their annual festivals including the Passover.For the normal difference between two dates I used the following formula formulaEg:$ From = strtotime ('{richiesta___dal}');$ To = strtotime ('{richiesta___al}');$ Diff = ($ al $ from) / 86400;return $ diff;and it works pretty well, but how can I calculate what I need?
I already have a function in php I calculate what I need but do not know how to apply it to the plugin calc.
Would you be so genitli to help me please.Thank you very much.
Eg php function:<? Phpgiornilavorativi function ($ StartDate, EndDate $){// Calculation of Easter Day until the last year validfor ($ i = 2015; $ i <= 2037; $ i ++) {$ Easter = date ("Y-m-d", easter_date ($ i));$ Array_pasqua [] = $ Passover;}
// Calculate the respective Pasquetteforeach ($ array_pasqua as $ easter) {list ($ year, $ month, $ day) = explode ("-", $ Easter);$ Pasquetta = mktime (0,0,0, dates ($ month), dates ($ day) + 1, dates ($ year));$ Array_pasquetta [] = $ Easter Monday;}
// These days are always holidays apart from the year$ GiorniFestivi =array ("01-01""04-06""01-06","04-25""05-01""06-02""08-15""10-04""11-01""12-08""12-25","12-26",);
$ Working = 0;
for ($ i = strtotime ($ StartDate); $ i <= strtotime ($ EndDate); $ i = strtotime ("+ 1 day", $ i)){$ Giorno_data = date ("w", $ s); // Check on the day: from 0 (Sun) to 6 (Sat)$ Mese_giorno = date ('m-d', $ i); // Comparison with gg always Holidays
// Finally I verify that the day is not a Saturday, Sunday or public holiday festive variable (Easter Monday);if ($ giorno_data! = 0 && $ giorno_data! = 6 &&! in_array ($ mese_giorno, $ giorniFestivi) &&! in_array ($ i, $ array_pasquetta)){$ Working ++;}
}
return $ working;}
giornilavorativi echo ("02/28/2015", "02/03/2015");?>
I already have a function in php I calculate what I need but do not know how to apply it to the plugin calc.
Would you be so genitli to help me please.Thank you very much.
Eg php function:<? Phpgiornilavorativi function ($ StartDate, EndDate $){// Calculation of Easter Day until the last year validfor ($ i = 2015; $ i <= 2037; $ i ++) {$ Easter = date ("Y-m-d", easter_date ($ i));$ Array_pasqua [] = $ Passover;}
// Calculate the respective Pasquetteforeach ($ array_pasqua as $ easter) {list ($ year, $ month, $ day) = explode ("-", $ Easter);$ Pasquetta = mktime (0,0,0, dates ($ month), dates ($ day) + 1, dates ($ year));$ Array_pasquetta [] = $ Easter Monday;}
// These days are always holidays apart from the year$ GiorniFestivi =array ("01-01""04-06""01-06","04-25""05-01""06-02""08-15""10-04""11-01""12-08""12-25","12-26",);
$ Working = 0;
for ($ i = strtotime ($ StartDate); $ i <= strtotime ($ EndDate); $ i = strtotime ("+ 1 day", $ i)){$ Giorno_data = date ("w", $ s); // Check on the day: from 0 (Sun) to 6 (Sat)$ Mese_giorno = date ('m-d', $ i); // Comparison with gg always Holidays
// Finally I verify that the day is not a Saturday, Sunday or public holiday festive variable (Easter Monday);if ($ giorno_data! = 0 && $ giorno_data! = 6 &&! in_array ($ mese_giorno, $ giorniFestivi) &&! in_array ($ i, $ array_pasquetta)){$ Working ++;}
}
return $ working;}
giornilavorativi echo ("02/28/2015", "02/03/2015");?>