/** * Set the month * * @param mixed $anIntOrString * @return void * @access private * @since 5/23/05 */ function setMonth($anIntOrString) { if (!$anIntOrString) { $this->month = NULL; } else { if (is_numeric($anIntOrString)) { $this->month = intval($anIntOrString); } else { $this->month = Month::indexOfMonth($anIntOrString); } } }
/** * Answer the days in this month on a given year. * * @param string $indexOrNameString * @param ingteger $yearInteger * @return integer * @access public * @since 5/5/05 * @static */ static function daysInMonthForYear($indexOrNameString, $yearInteger) { if (is_numeric($indexOrNameString)) { $index = $indexOrNameString; } else { $index = Month::indexOfMonth($indexOrNameString); } if ($index < 1 | $index > 12) { $errorString = $index . " is not a valid month index."; if (function_exists('throwError')) { throwError(new Error($errorString)); } else { die($errorString); } } $monthDays = ChronologyConstants::DaysInMonth(); $days = $monthDays[$index]; if ($index == 2 && Year::isYearLeapYear($yearInteger)) { return $days + 1; } else { return $days; } }
/** * Create a new instance. * * @param integer $anIntYear * @param integer $anIntOrStringMonth * @param integer $anIntDay * @param integer $anIntHour * @param integer $anIntMinute * @param integer $anIntSecond * @param object Duration $aDurationOffset * @param optional string $class DO NOT USE OUTSIDE OF PACKAGE. * This parameter is used to get around the limitations of not being * able to find the class of the object that recieved the initial * method call. * @return object DateAndTime * @access public * @static * @since 5/4/05 */ static function withYearMonthDayHourMinuteSecondOffset($anIntYear, $anIntOrStringMonth, $anIntDay, $anIntHour, $anIntMinute, $anIntSecond, $aDurationOffset, $class = 'DateAndTime') { // Validate our passed class name. if (!(strtolower($class) == strtolower('DateAndTime') || is_subclass_of(new $class(), 'DateAndTime'))) { die("Class, '{$class}', is not a subclass of 'DateAndTime'."); } // Ensure that we have no days less than 1. if ($anIntDay < 1) { $anIntDay = 1; } if (is_numeric($anIntOrStringMonth)) { $monthIndex = $anIntOrStringMonth; } else { $monthIndex = Month::indexOfMonth($anIntOrStringMonth); } $p = intval(($monthIndex - 14) / 12); $q = $anIntYear + 4800 + $p; $r = $monthIndex - 2 - 12 * $p; $s = intval(($anIntYear + 4900 + $p) / 100); $julianDayNumber = intval(1461 * $q / 4) + intval(367 * $r / 12) - intval(3 * $s / 4) + ($anIntDay - 32075); $since = Duration::withDaysHoursMinutesSeconds($julianDayNumber, $anIntHour, $anIntMinute, $anIntSecond); if (is_null($aDurationOffset)) { $offset = DateAndTime::localOffset(); } else { $offset = $aDurationOffset; } $dateAndTime = new $class(); $dateAndTime->ticksOffset($since->ticks(), $offset); return $dateAndTime; }