mirror of
https://github.com/simshaun/recurr.git
synced 2025-01-17 16:08:14 +01:00
Fixes #7
This commit is contained in:
parent
11a8fc05e1
commit
70855859d4
@ -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;
|
||||
}
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user