Hi,
thanks for this code very useful and good way to handle the opening hours, but I am still having a issue
after midnight..
If we set the config like the documentation it wont work..
'thu' => array('11:00-1:30'), // Open late
'fri' => array('11:00-20:30'),
Here is the problem when I am in Thursday late (Friday early morning 1:00am)
the function is_open consider I am in Friday and go to check the opening time of Friday but never go to check the day before.
On this case it's true Friday is close but I am still open with Thursday config until 1:30am (Friday)
Solutions :
Update the documentation
'thu' => array('11:00-00:00'), // Open late
'fri' => array('00:00-1:30','11:00-20:30')
2. Or check the yesterday date with something like this :
public function hours_yesterday() {
$yesterday = strtotime("yesterday midnight");
$yday = strtolower(date('D',strtotime("-1 days")));
$exceptions = $this->exceptions;
$hours_yesterday = $this->hours[$yday];
if($exceptions) {
foreach($exceptions as $ex_day => $ex_hours) {
//echo 'ex' . date('r', strtotime($ex_day + '/2014'));
//echo 'today' . date('r', $today);
if(strtotime($ex_day) == $yesterday) {
// Today is an exception, use alternate hours instead
$hours_yesterday = $ex_hours;
}
}
}
return $hours_yesterday;
}
// Returns boolean
public function is_open() {
// today
// bla bla bla
Hi, thanks for this code very useful and good way to handle the opening hours, but I am still having a issue after midnight..
If we set the config like the documentation it wont work.. 'thu' => array('11:00-1:30'), // Open late 'fri' => array('11:00-20:30'),
Here is the problem when I am in Thursday late (Friday early morning 1:00am) the function is_open consider I am in Friday and go to check the opening time of Friday but never go to check the day before. On this case it's true Friday is close but I am still open with Thursday config until 1:30am (Friday)
Solutions :
// Returns boolean public function is_open() { // today // bla bla bla
}
Ps : Just draft code need to be improved and factorised !!