コード例 #1
0
ファイル: TimeDate.php プロジェクト: klr2003/sourceread
 /**
  * function getDateFromRules($year, $startMonth, $startDate, $weekday, $startTime )
  * Converts the rules for a timezones dst into a string representation of a date for the given year
  *
  * @param STRING(YEAR) $year
  * @param INT(MONTH INDEX) $startMonth
  * @param INT(DATE INDEX) $startDate
  * @param INT(WEEKDAY INDEX) $weekday
  * @param INT(START TIME IN SECONDS) $startTime
  * @return unknown
  */
 function getDateFromRules($year, $startMonth, $startDate, $weekday, $startTime)
 {
     if ($weekday < 0) {
         return date('Y-m-d H:i:s', strtotime("{$year}-{$startMonth}-{$startDate}") + $startTime);
     }
     $dayname = TimeDate::getWeekDayName($weekday);
     if ($startDate > 0) {
         $startMonth--;
     }
     $month = TimeDate::getMonthName($startMonth);
     $startWeek = floor($startDate / 7);
     //echo "$startWeek week $dayname - $month 1, $year<br>";
     return date('Y-m-d H:i:s', strtotime("{$startWeek} week {$dayname}", strtotime("{$month} 1, {$year}")) + $startTime);
 }