I need to check the given period will at least be covers the one night of the weekend(saturday night or sunday night) (refer the wiki article about the rule).
I found this question that, how to check the date whether it is fall on weekend or not,
function isWeekend($date) {
$weekDay = date('w', strtotime($date));
return ($weekDay == 0 || $weekDay == 6);
}
But still I am struggle with how to implement a function to get following sample results for given periods,
Sample periods and results:
04-01-2016 / 07-01-2016 : false
04-01-2016 / 09-01-2016 : false
04-01-2016 / 10-01-2016 : true (covers saturday night)
03-01-2016 / 07-01-2016 : true (covers sunday night)
04-01-2016 / 14-01-2016 : true (covers a full weekend)
The rule should wither start date is falls on weekend or end date is falls on sunday or the period covers at a full weekend.