Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15414098
D16610.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D16610.id.diff
View Options
diff --git a/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php b/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php
--- a/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php
+++ b/src/parser/calendar/data/PhutilCalendarRecurrenceRule.php
@@ -273,7 +273,7 @@
public function setByWeekNumber(array $by_week_number) {
$this->assertByRange('BYWEEKNO', $by_week_number, -53, 53, false);
- $this->byWeekNumber = $by_week_number;
+ $this->byWeekNumber = array_fuse($by_week_number);
return $this;
}
@@ -572,8 +572,10 @@
// month", so we need to expand the month set if the constraint is present.
$by_monthday = $this->getByMonthDay();
- // Likewise, we need to generate all months if we have BYYEARDAY.
+ // Likewise, we need to generate all months if we have BYYEARDAY or
+ // BYWEEKNO.
$by_yearday = $this->getByYearDay();
+ $by_weekno = $this->getByWeekNumber();
while (!$this->setMonths) {
$this->nextYear();
@@ -582,6 +584,7 @@
|| $by_month
|| $by_monthday
|| $by_yearday
+ || $by_weekno
|| ($scale < self::SCALE_MONTHLY);
if ($is_dynamic) {
@@ -867,10 +870,10 @@
$first_weekday = $weekday;
for ($year_day = 1; $year_day <= $max_day; $year_day++) {
$first_weekday = ($first_weekday + 1) % 7;
+ $first_week_size++;
if ($first_weekday === $weekday_index) {
break;
}
- $first_week_size++;
}
if ($first_week_size >= 4) {
@@ -929,7 +932,7 @@
$week_value = -$week_number + $week - 1;
}
- $info['-week'] = $week_value;
+ $info_map[$key]['-week'] = $week_value;
}
return array(
diff --git a/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php b/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php
--- a/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php
+++ b/src/parser/calendar/data/__tests__/PhutilCalendarRecurrenceRuleTestCase.php
@@ -219,6 +219,51 @@
'19980719',
);
+ $tests[] = array(
+ 'BYYEARDAY' => array(-365, -266, -166, -1),
+ 'COUNT' => 4,
+ );
+ $expect[] = array(
+ '19971231',
+ '19980101',
+ '19980410',
+ '19980719',
+ );
+
+ $tests[] = array(
+ 'BYYEARDAY' => array(1, 100, 200, 365),
+ 'BYMONTH' => array(4, 7),
+ 'COUNT' => 4,
+ );
+ $expect[] = array(
+ '19980410',
+ '19980719',
+ '19990410',
+ '19990719',
+ );
+
+ $tests[] = array(
+ 'BYYEARDAY' => array(-365, -266, -166, -1),
+ 'BYMONTH' => array(4, 7),
+ 'COUNT' => 4,
+ );
+ $expect[] = array(
+ '19980410',
+ '19980719',
+ '19990410',
+ '19990719',
+ );
+
+ $tests[] = array(
+ 'BYWEEKNO' => array(20),
+ );
+ $expect[] = array(
+ '19980511',
+ '19980512',
+ '19980513',
+ );
+
+
$this->assertRules(
array(
'FREQ' => 'YEARLY',
@@ -265,6 +310,11 @@
$rrule->setByYearDay($by_yearday);
}
+ $by_weekno = idx($options, 'BYWEEKNO');
+ if ($by_weekno) {
+ $rrule->setByWeekNumber($by_weekno);
+ }
+
$set = id(new PhutilCalendarRecurrenceSet())
->addSource($rrule);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 11:10 PM (1 h, 34 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7384321
Default Alt Text
D16610.id.diff (3 KB)
Attached To
Mode
D16610: Fix some RRULE bugs with BYWEEKNO
Attached
Detach File
Event Timeline
Log In to Comment