aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/CalDAV/EventReaderRDate.php
blob: 20234d06c00d5bdad24922f7269d208b137367d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */

namespace OCA\DAV\CalDAV;

use DateTime;

class EventReaderRDate extends \Sabre\VObject\Recur\RDateIterator {

	public function concludes(): ?DateTime {
		return $this->concludesOn();
	}

	public function concludesAfter(): ?int {
		return !empty($this->dates) ? count($this->dates) : null;
	}

	public function concludesOn(): ?DateTime {
		if (count($this->dates) > 0) {
			return new DateTime(
				$this->dates[array_key_last($this->dates)],
				$this->startDate->getTimezone()
			);
		}

		return null;
	}

}