Page MenuHomePhabricator

D16607.diff
No OneTemporary

D16607.diff

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
@@ -681,7 +681,7 @@
$by_weekno,
$week_start) {
- $year_map = $this->getYearMap($this->cursorYear, $week_start);
+ $year_map = $this->getYearMap($this->stateYear, $week_start);
$selection = array();
if ($interval_week) {
@@ -813,7 +813,7 @@
// year starts on and avoid the cost of a DateTime construction, but I
// wasn't able to turn it up and we only need to do this once per year.
$datetime = new DateTime("{$year}-01-01", new DateTimeZone('UTC'));
- $weekday = $datetime->format('w');
+ $weekday = (int)$datetime->format('w');
if ($is_leap) {
$max_day = 366;
@@ -870,6 +870,7 @@
$key = "{$month_number}M{$month_day}D";
$info = array(
+ 'year' => $year,
'key' => $key,
'month' => $month_number,
'monthday' => $month_day,
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
@@ -149,6 +149,25 @@
'19971003',
);
+ $tests[] = array(
+ 'BYMONTH' => array(1, 3),
+ 'BYMONTHDAY' => array(5, 7),
+ );
+ $expect[] = array(
+ '19980105',
+ '19980107',
+ '19980305',
+ );
+
+ $tests[] = array(
+ 'BYDAY' => array('TU', 'TH'),
+ );
+ $expect[] = array(
+ '19970902',
+ '19970904',
+ '19970909',
+ );
+
$this->assertRules(
array(
'FREQ' => 'YEARLY',
@@ -175,6 +194,11 @@
$rrule->setInterval($interval);
}
+ $by_day = idx($options, 'BYDAY');
+ if ($by_day) {
+ $rrule->setByDay($by_day);
+ }
+
$by_month = idx($options, 'BYMONTH');
if ($by_month) {
$rrule->setByMonth($by_month);

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 24, 12:14 AM (4 d, 10 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7578263
Default Alt Text
D16607.diff (2 KB)

Event Timeline