Skip to content

OCP\Calendar\IManager::search with options lists all recurring events even outside search range #25734

Description

@dartcafe

actual behavior

The return is a list of events within this timespan but also a list with all(!) recurring dates, whether they have an event in the timerange or not. I guess, these are events with the first occurrency before the timespan and the last after the timespan. Additionally only the timestamps of the first occurrency is available. Interpreting the recurring rules gets to complex tbh.

One time events get returned correctly.

Expected behavior

  • list only occurrencies of recurring events, which actually take place inside the defined timespan and
  • expand the DTSTART and DTEND to the start and end time of the relevant occurrency

more info

Calling OCP\Calendar\IManager::search('', ['SUMMARY'], ['timerange' => ['start' => $from, 'end' => $to]]);
where $from and $to are objects of DateTime

Affected code https://github.com/nextcloud/polls/blob/649c90415d3b3007e6576b880d78947f551c4aaa/lib/Service/CalendarService.php#L58-L84

Example:

json_encode($from)  {"date":"2021-03-03 10:00:00.000000","timezone_type":3,"timezone":"UTC"}
json_encode($to): = {"date":"2021-03-03 12:00:00.000000","timezone_type":3,"timezone":"UTC"}

As a result we get dates outside the defined timerange:

  • 2021-02-16 13:00:00 (recurring 2021-02-23 13:00:00, 2021-03-02 13:00:00, 2021-03-09 13:00:00, ...) (
  • 2021-02-18 22:30:00 (recurring 2021-02-25 22:30:00, 21-03-04 22:30:00, ...)
  • ... (Complete result below)

See also nextcloud/polls#1185, where all birthdays were returned.

Complete result:

[{
	"id": "50",
	"type": "VEVENT",
	"uid": "fda60c8d-b8f4-4fa4-b7a9-69af79b0d118",
	"uri": "1B2F0370-19B6-42BD-9FA2-746FC509B0FE.ics",
	"objects": [{
		"CREATED": [{
				"date": "2021-01-25 16:29:07.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"DTSTAMP": [{
				"date": "2021-02-05 19:41:07.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"LAST-MODIFIED": [{
				"date": "2021-02-05 19:41:07.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"SEQUENCE": [6, []],
		"UID": ["fda60c8d-b8f4-4fa4-b7a9-69af79b0d118", []],
		"DTSTART": [{
			"date": "2021-02-16 13:00:00.000000",
			"timezone_type": 3,
			"timezone": "Europe\/Berlin"
		}, {
			"TZID": "Europe\/Berlin"
		}],
		"DTEND": [{
			"date": "2021-02-16 14:10:00.000000",
			"timezone_type": 3,
			"timezone": "Europe\/Berlin"
		}, {
			"TZID": "Europe\/Berlin"
		}],
		"SUMMARY": ["Phone call with Donald", []],
		"RRULE": ["FREQ=WEEKLY;BYDAY=TU;UNTIL=20211227T230000Z", []]
	}],
	"timezones": [{
		"DAYLIGHT": [{
			"TZOFFSETFROM": [
				["+0100", []]
			],
			"TZOFFSETTO": [
				["+0200", []]
			],
			"TZNAME": [
				["CEST", []]
			],
			"DTSTART": [
				[{
						"date": "1970-03-29 02:00:00.000000",
						"timezone_type": 3,
						"timezone": "UTC"
					},
					[]
				]
			],
			"RRULE": [
				["FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU", []]
			]
		}],
		"STANDARD": [{
			"TZOFFSETFROM": [
				["+0200", []]
			],
			"TZOFFSETTO": [
				["+0100", []]
			],
			"TZNAME": [
				["CET", []]
			],
			"DTSTART": [
				[{
						"date": "1970-10-25 03:00:00.000000",
						"timezone_type": 3,
						"timezone": "UTC"
					},
					[]
				]
			],
			"RRULE": [
				["FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU", []]
			]
		}],
		"TZID": ["Europe\/Berlin", []]
	}]
}, {
	"id": "53",
	"type": "VEVENT",
	"uid": "14114df6-d63f-4ef2-ae71-ff9b9262c86f",
	"uri": "B08DB277-5222-4643-932C-A22085B0295A.ics",
	"objects": [{
		"CREATED": [{
				"date": "2021-02-05 19:45:13.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"DTSTAMP": [{
				"date": "2021-02-05 19:46:32.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"LAST-MODIFIED": [{
				"date": "2021-02-05 19:46:32.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"SEQUENCE": [3, []],
		"UID": ["14114df6-d63f-4ef2-ae71-ff9b9262c86f", []],
		"DTSTART": [{
			"date": "2021-02-18 20:00:00.000000",
			"timezone_type": 3,
			"timezone": "Europe\/Berlin"
		}, {
			"TZID": "Europe\/Berlin"
		}],
		"DTEND": [{
			"date": "2021-02-18 22:30:00.000000",
			"timezone_type": 3,
			"timezone": "Europe\/Berlin"
		}, {
			"TZID": "Europe\/Berlin"
		}],
		"SUMMARY": ["Dinner with Secret", []],
		"RRULE": ["FREQ=WEEKLY;BYDAY=TH;UNTIL=20211229T230000Z", []]
	}],
	"timezones": [{
		"DAYLIGHT": [{
			"TZOFFSETFROM": [
				["+0100", []]
			],
			"TZOFFSETTO": [
				["+0200", []]
			],
			"TZNAME": [
				["CEST", []]
			],
			"DTSTART": [
				[{
						"date": "1970-03-29 02:00:00.000000",
						"timezone_type": 3,
						"timezone": "UTC"
					},
					[]
				]
			],
			"RRULE": [
				["FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU", []]
			]
		}],
		"STANDARD": [{
			"TZOFFSETFROM": [
				["+0200", []]
			],
			"TZOFFSETTO": [
				["+0100", []]
			],
			"TZNAME": [
				["CET", []]
			],
			"DTSTART": [
				[{
						"date": "1970-10-25 03:00:00.000000",
						"timezone_type": 3,
						"timezone": "UTC"
					},
					[]
				]
			],
			"RRULE": [
				["FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU", []]
			]
		}],
		"TZID": ["Europe\/Berlin", []]
	}]
}, {
	"id": "57",
	"type": "VEVENT",
	"uid": "4db07993-7a05-4570-8dd3-4a82a1a1e7c1",
	"uri": "67CBF600-27C7-407F-979C-FD291BD0DEFD.ics",
	"objects": [{
		"CREATED": [{
				"date": "2021-02-20 13:27:34.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"DTSTAMP": [{
				"date": "2021-02-20 13:28:16.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"LAST-MODIFIED": [{
				"date": "2021-02-20 13:28:16.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"SEQUENCE": [2, []],
		"UID": ["4db07993-7a05-4570-8dd3-4a82a1a1e7c1", []],
		"DTSTART": [{
			"date": "2021-01-31 00:00:00.000000",
			"timezone_type": 3,
			"timezone": "UTC"
		}, {
			"VALUE": "DATE"
		}],
		"DTEND": [{
			"date": "2021-02-01 00:00:00.000000",
			"timezone_type": 3,
			"timezone": "UTC"
		}, {
			"VALUE": "DATE"
		}],
		"SUMMARY": ["Monthly", []],
		"RRULE": ["FREQ=MONTHLY;COUNT=12;BYMONTHDAY=31", []]
	}],
	"timezones": []
}, {
	"id": "58",
	"type": "VEVENT",
	"uid": "1ce9cba9-0954-4c22-b577-6d0a8ffde7dd",
	"uri": "AC5FFE15-B504-4247-9907-AC94CB2256DD.ics",
	"objects": [{
		"CREATED": [{
				"date": "2021-02-20 13:28:39.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"DTSTAMP": [{
				"date": "2021-02-20 13:29:11.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"LAST-MODIFIED": [{
				"date": "2021-02-20 13:29:11.000000",
				"timezone_type": 3,
				"timezone": "UTC"
			},
			[]
		],
		"SEQUENCE": [2, []],
		"UID": ["1ce9cba9-0954-4c22-b577-6d0a8ffde7dd", []],
		"DTSTART": [{
			"date": "2021-01-01 00:00:00.000000",
			"timezone_type": 3,
			"timezone": "UTC"
		}, {
			"VALUE": "DATE"
		}],
		"DTEND": [{
			"date": "2021-01-02 00:00:00.000000",
			"timezone_type": 3,
			"timezone": "UTC"
		}, {
			"VALUE": "DATE"
		}],
		"SUMMARY": ["Monatlich 1", []],
		"RRULE": ["FREQ=MONTHLY;COUNT=12;BYMONTHDAY=1", []]
	}],
	"timezones": []
}]

Metadata

Metadata

Assignees

No one assigned

    Labels

    0. Needs triagePending check for reproducibility or if it fits our roadmapbugneeds info

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions