/** * Calculates the required DST change and returns a Timestamp Array * * @package core * @category time * @uses HOURSECS * @uses MINSECS * @param int|string $year Int or String Year to focus on * @param object $timezone Instatiated Timezone object * @return array|null Array dst => xx, 0 => xx, std => yy, 1 => yy or null */ function dst_changes_for_year($year, $timezone) { if ($timezone->dst_startday == 0 && $timezone->dst_weekday == 0 && $timezone->std_startday == 0 && $timezone->std_weekday == 0) { return null; } $monthdaydst = find_day_in_month($timezone->dst_startday, $timezone->dst_weekday, $timezone->dst_month, $year); $monthdaystd = find_day_in_month($timezone->std_startday, $timezone->std_weekday, $timezone->std_month, $year); list($dsthour, $dstmin) = explode(':', $timezone->dst_time); list($stdhour, $stdmin) = explode(':', $timezone->std_time); $timedst = make_timestamp($year, $timezone->dst_month, $monthdaydst, 0, 0, 0, 99, false); $timestd = make_timestamp($year, $timezone->std_month, $monthdaystd, 0, 0, 0, 99, false); // Instead of putting hour and minute in make_timestamp(), we add them afterwards. // This has the advantage of being able to have negative values for hour, i.e. for timezones // where GMT time would be in the PREVIOUS day than the local one on which DST changes. $timedst += $dsthour * HOURSECS + $dstmin * MINSECS; $timestd += $stdhour * HOURSECS + $stdmin * MINSECS; return array('dst' => $timedst, 0 => $timedst, 'std' => $timestd, 1 => $timestd); }
case 'weeknext': $startweekday = get_user_preferences('calendar_startwday', CALENDAR_STARTING_WEEKDAY); $startmonthday = find_day_in_month($now['mday'] + 1, $startweekday, $now['mon'], $now['year']); $startmonth = $now['mon']; $startyear = $now['year']; if ($startmonthday > calendar_days_in_month($startmonth, $startyear)) { list($startmonth, $startyear) = calendar_add_month($startmonth, $startyear); $startmonthday = find_day_in_month(1, $startweekday, $startmonth, $startyear); } $timestart = make_timestamp($startyear, $startmonth, $startmonthday); $endmonthday = $startmonthday + 7; $endmonth = $startmonth; $endyear = $startyear; if ($endmonthday > calendar_days_in_month($endmonth, $endyear)) { list($endmonth, $endyear) = calendar_add_month($endmonth, $endyear); $endmonthday = find_day_in_month(1, $startweekday, $endmonth, $endyear); } $timeend = make_timestamp($endyear, $endmonth, $endmonthday) - 1; break; case 'monthnow': $timestart = make_timestamp($now['year'], $now['mon'], 1); $timeend = make_timestamp($now['year'], $now['mon'], calendar_days_in_month($now['mon'], $now['year']), 23, 59, 59); break; case 'monthnext': list($nextmonth, $nextyear) = calendar_add_month($now['mon'], $now['year']); $timestart = make_timestamp($nextyear, $nextmonth, 1); $timeend = make_timestamp($nextyear, $nextmonth, calendar_days_in_month($nextmonth, $nextyear), 23, 59, 59); break; case 'recentupcoming': //Events in the last 5 or next 60 days $timestart = time() - 432000;