/** * Test Duplicate after changing one of the properties */ public function testDuplicateDifferent() { $date = new w2p_Utilities_Date('2010-09-14 10:00:00'); $date2 = $date->duplicate(); $date->minute = 15; $this->assertNotEquals($date, $date2); }
public function hook_calendar($userId) { $date = new w2p_Utilities_Date(w2PgetParam($_GET, 'date', null)); $date->setTime(0, 0, 0); $start = $date->duplicate(); $end = $date->duplicate(); $view = w2PgetParam($_GET, 'a', 'month_view'); switch ($view) { case 'day_view': break; case 'week_view': $end->addDays(6); break; case 'index': case 'month_view': $start->setDay(1); $end->setDay($date->getDaysInMonth()); break; case 'year_view': $start->setMonth(1); $start->setDay(1); $end->setMonth(12); $end->setDay(31); break; } $end->setTime(23, 59, 59); $holidays = HolidayFunctions::getHolidaysForDatespan($start, $end, $userId); $itemsList = array(); foreach ($holidays as $i => $holiday) { $date = $holiday['startDate']; $end = $holiday['endDate']; while (!$date->after(clone $end)) { $itemsList[] = array('id' => $holiday['id'], 'name' => $holiday['name'], 'startDate' => $date->format(FMT_TIMESTAMP_DATE), 'endDate' => $date->format(FMT_TIMESTAMP_DATE), 'description' => $holiday['description']); $date = $date->getNextDay(); } } return $itemsList; }
// establish the focus 'date' $date = w2PgetParam($_GET, 'date', null); if (!$date) { $date = new w2p_Utilities_Date(); } else { $date = new w2p_Utilities_Date($date); } $date->setDay(1); $date->setMonth(1); $date->setTime(0, 0, 0); $year = $date->getYear(); $prev_year = $date->format(FMT_TIMESTAMP_DATE); $prev_year = (int) ($prev_year - 10000); $next_year = $date->format(FMT_TIMESTAMP_DATE); $next_year = (int) ($next_year + 10000); $start = $date->duplicate(); $end = $date->duplicate(); $end->setMonth(12); $end->setDay(31); $end->setTime(23, 59, 59); $holidays = array(); $holidaysList = HolidayFunctions::getDefaultCalendarHolidaysForDatespan($start, $end); foreach ($holidaysList as $holiday) { $id = 0; $type = $holiday['type']; $description = $holiday['description'] ? $holiday['description'] : ""; $name = $holiday['name'] ? $holiday['name'] : ""; $odate = $holiday['startDate']; $oend = $holiday['endDate']; $cdate = clone $odate; while (!$cdate->after(clone $oend)) {