/** * Create a new object starting from midnight * * @param object DateAndTime $aDateAndTime * @param object Duration $aDuration * @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 Year * @access public * @since 5/5/05 * @static */ static function startingDuration($aDateAndTime, $aDuration, $class = 'Year') { // Validate our passed class name. if (!(strtolower($class) == strtolower('Year') || is_subclass_of(new $class(), 'Year'))) { die("Class, '{$class}', is not a subclass of 'Year'."); } $asDateAndTime = $aDateAndTime->asDateAndTime(); $midnight = $asDateAndTime->atMidnight(); $year = new $class(); $year->setStart($midnight); $year->setDuration(Duration::withDays(Year::getDaysInYear($midnight->year()))); return $year; }