This commit is contained in:
Shaun Simmons 2014-01-06 19:56:46 -05:00
parent 11a8fc05e1
commit 70855859d4
2 changed files with 9 additions and 21 deletions

View File

@ -431,22 +431,9 @@ class DateUtil
public static function getDateTimeByDayOfYear($dayOfYear, $year, \DateTimeZone $timezone)
{
if (null === self::$leapBug) {
self::$leapBug = self::hasLeapYearBug();
}
$isLeapYear = self::isLeapYear($year);
$dtTmp = \DateTime::createFromFormat(
'z Y',
($isLeapYear && self::$leapBug && $dayOfYear > 59
? $dayOfYear - 1 : $dayOfYear).' '.$year,
$timezone
);
if ($isLeapYear && self::$leapBug && $dayOfYear == 59) {
$dtTmp->modify('-1 day');
}
$dtTmp = new \DateTime('now', $timezone);
$dtTmp->setDate($year, 1, 1);
$dtTmp->modify("+$dayOfYear day");
return $dtTmp;
}

View File

@ -565,19 +565,20 @@ class RecurrenceRuleTransformer
break;
case RecurrenceRule::FREQ_WEEKLY:
if ($weekStart > $dtInfo->dayOfWeek) {
$day += -($dtInfo->dayOfWeek + 1 + (6 - $weekStart)) +
$delta = ($dtInfo->dayOfWeek + 1 + (6 - $weekStart)) * -1 +
$rule->getInterval() * 7;
} else {
$day += -($dtInfo->dayOfWeek - $weekStart) +
$delta = ($dtInfo->dayOfWeek - $weekStart) * -1 +
$rule->getInterval() * 7;
}
$dt->setDate($year, $month, $day);
++$total;
$dt->modify("+$delta day");
$year = $dt->format('Y');
$month = $dt->format('n');
$day = $dt->format('j');
break;
case RecurrenceRule::FREQ_DAILY:
$dt->modify('+'.$rule->getInterval().' day');
$day = $dt->format('j');
$year = $dt->format('Y');
$month = $dt->format('n');
$day = $dt->format('j');