base implemantation for rrule
Signed-off-by: dartcafe <github@dartcafe.de>
This commit is contained in:
Родитель
edbe5a851f
Коммит
b87b6e2344
|
@ -43,6 +43,7 @@
|
|||
"psalm:baseline:update": "php vendor/vimeo/psalm/psalm --update-baseline"
|
||||
},
|
||||
"require": {
|
||||
"league/commonmark": "^2.1"
|
||||
"league/commonmark": "^2.1",
|
||||
"rlanvin/php-rrule": "^2.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "446637bd32e4be9092d9decd2adbcde9",
|
||||
"content-hash": "a551a3501d1e142e36180aa7d1c4d3a6",
|
||||
"packages": [
|
||||
{
|
||||
"name": "dflydev/dot-access-data",
|
||||
|
@ -466,6 +466,55 @@
|
|||
},
|
||||
"time": "2019-01-08T18:20:26+00:00"
|
||||
},
|
||||
{
|
||||
"name": "rlanvin/php-rrule",
|
||||
"version": "v2.3.1",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/rlanvin/php-rrule.git",
|
||||
"reference": "5ef9eedb5d32e0999b18ef0d0c18d463c419cf71"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/rlanvin/php-rrule/zipball/5ef9eedb5d32e0999b18ef0d0c18d463c419cf71",
|
||||
"reference": "5ef9eedb5d32e0999b18ef0d0c18d463c419cf71",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpmd/phpmd": "@stable",
|
||||
"phpunit/phpunit": "^5.7|^6.5|^8.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-intl": "Intl extension is needed for humanReadable()"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"RRule\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"description": "Lightweight and fast recurrence rules for PHP (RFC 5545)",
|
||||
"homepage": "https://github.com/rlanvin/php-rrule",
|
||||
"keywords": [
|
||||
"date",
|
||||
"ical",
|
||||
"recurrence",
|
||||
"recurring",
|
||||
"rrule"
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/rlanvin/php-rrule/issues",
|
||||
"source": "https://github.com/rlanvin/php-rrule/tree/v2.3.1"
|
||||
},
|
||||
"time": "2022-04-22T08:45:04+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
"version": "v2.5.1",
|
||||
|
@ -5816,5 +5865,5 @@
|
|||
"platform-overrides": {
|
||||
"php": "7.4.0"
|
||||
},
|
||||
"plugin-api-version": "2.3.0"
|
||||
"plugin-api-version": "2.0.0"
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
namespace OCA\Polls\Model;
|
||||
|
||||
use \OCP\Calendar\ICalendar;
|
||||
use RRule\RRule;
|
||||
|
||||
class CalendarEvent implements \JsonSerializable {
|
||||
|
||||
|
@ -93,8 +94,21 @@ class CalendarEvent implements \JsonSerializable {
|
|||
return isset($this->event['RRULE']);
|
||||
}
|
||||
|
||||
public function getRecurrencies(): string {
|
||||
return 'not implementend yet';
|
||||
public function getOccurencies(): array {
|
||||
$occurencies = [];
|
||||
|
||||
if ($this->getHasRRule()) {
|
||||
$rrule = new RRule($this->getRRule());
|
||||
|
||||
foreach ($rrule as $occurence) {
|
||||
$occurencies[] = $occurence->format('r');
|
||||
if (count($occurencies) > 99) {
|
||||
return $occurencies;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $occurencies;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,13 +118,16 @@ class CalendarEvent implements \JsonSerializable {
|
|||
*/
|
||||
public function getRRule() {
|
||||
$rRule = [];
|
||||
$baseRRule = ['DTSTART' => $this->event['DTSTART'][0]];
|
||||
|
||||
if ($this->getHasRRule()) {
|
||||
preg_match_all("/([^;= ]+)=([^;= ]+)/", $this->event['RRULE'][0], $r);
|
||||
$rRule = array_combine($r[1], $r[2]);
|
||||
}
|
||||
return $rRule;
|
||||
return array_merge($baseRRule, $rRule);
|
||||
}
|
||||
|
||||
|
||||
public function getStatus(): string {
|
||||
return $this->event['STATUS'][0] ?? '';
|
||||
}
|
||||
|
@ -136,7 +153,7 @@ class CalendarEvent implements \JsonSerializable {
|
|||
'calDav' => $this->getCalDav(),
|
||||
'hasRRule' => $this->getHasRRule(),
|
||||
'rRule' => $this->getRRule(),
|
||||
'recurrencies' => $this->getRecurrencies(),
|
||||
'occurencies' => $this->getOccurencies(),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ class CalendarService {
|
|||
}
|
||||
}
|
||||
/**
|
||||
* getEvents - get events from the user's calendars inside given timespan
|
||||
* getEventsLegacy - get events from the user's calendars inside given timespan
|
||||
*
|
||||
* @return CalendarEvent[]
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче