//closes if-elseif-else $widget .= '</p>'; } } //closes if-elseif-else //reset match to false to start the loop over $match = false; } //closes for $widget .= ' </div>'; } else { if ($display == 'today') { // grab hours based on date and location // returns: OPEN_TIME, CLOSE_TIME, IS_CLOSED, TYPE, CATEGORY $today = getHoursByDate($currentdate, $location1, $type1); $widget = ' <div class="hours-widget"> <p><strong>Today\'s Hours:</strong> '; // if hours returned if ($today) { // display library hours as closed, 24 hrs or a range if ($today[0]['is_closed'] == 1) { $widget .= 'Closed All Day</p>'; } else { if ($today[0]['open_time'] == $today[0]['close_time'] && $today[0]['is_closed'] == 0) { $widget .= 'Open 24 Hrs</p>'; } else { $widget .= displayTime($today[0]['open_time']) . ' - ' . displayTime($today[0]['close_time']) . '</p>'; } }
//$currentday = date('l', strtotime($currentdate)); //$currenttime = '01:00:00'; // find first monday of the year $firstmon = strtotime("mon jan {$currentyear}"); // weeks offset is always one less than current week $weeksoffset = $currentweek - 1; // calculate this week's monday $thismon = date('Y-m-d', strtotime("+{$weeksoffset} week " . date('Y-m-d', $firstmon))); // put the week's dates in an array $ymd = array($thismon, date('Y-m-d', strtotime($thismon) + 1 * 86400), date('Y-m-d', strtotime($thismon) + 2 * 86400), date('Y-m-d', strtotime($thismon) + 3 * 86400), date('Y-m-d', strtotime($thismon) + 4 * 86400), date('Y-m-d', strtotime($thismon) + 5 * 86400), date('Y-m-d', strtotime($thismon) + 6 * 86400)); $weeklyhours = array(); // pull in each days hours and add it to a weekly array for ($i = 0; $i < 7; $i++) { // grab hours based on date and location (library hours) // returns: OPEN_TIME, CLOSE_TIME, IS_CLOSED, TYPE, CATEGORY $dailyhours = getHoursByDate($ymd[$i], $location_id, $type_id); array_push($weeklyhours, $dailyhours); } //closes for // set up match as false outside the loop $match = false; // display week's hours, collapsing where appropriate for ($i = 0; $i < 7; $i++) { // variables to compare the next values $next_open = isset($weeklyhours[$i + 1][0]['open_time']) ? $weeklyhours[$i + 1][0]['open_time'] : '0'; $next_close = isset($weeklyhours[$i + 1][0]['close_time']) ? $weeklyhours[$i + 1][0]['close_time'] : '0'; $next_closed = isset($weeklyhours[$i + 1][0]['is_closed']) ? $weeklyhours[$i + 1][0]['is_closed'] : '0'; // if the next set of hours is the same, set the range start date, change match to true, break the loop if ($weeklyhours[$i][0]['open_time'] == $next_open && $weeklyhours[$i][0]['close_time'] == $next_close && $weeklyhours[$i][0]['is_closed'] == $next_closed && $match == false) { $start_range = date('D', strtotime($ymd[$i])); $match = true;