/** * Create a new object starting now, with a given duration. * Override - as each Week has a defined duration * * @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 Week * @access public * @since 5/5/05 * @static */ static function startingDuration($aDateAndTime, $aDuration, $class = 'Week') { // Validate our passed class name. if (!(strtolower($class) == strtolower('Week') || is_subclass_of(new $class(), 'Week'))) { die("Class, '{$class}', is not a subclass of 'Week'."); } $asDateAndTime = $aDateAndTime->asDateAndTime(); $midnight = $asDateAndTime->atMidnight(); $dayNames = ChronologyConstants::DayNames(); $temp = $midnight->dayOfWeek() + 7 - array_search(Week::startDay(), $dayNames); $delta = abs($temp - intval($temp / 7) * 7); $adjusted = $midnight->minus(Duration::withDays($delta)); $obj = parent::startingDuration($adjusted, Duration::withWeeks(1), $class); return $obj; }