Files
glb_adm 01acfa3b40
Type checking / changes (push) Has been cancelled
Type checking / test (push) Has been cancelled
Type checking / typescript-summary (push) Has been cancelled
Node tests / changes (push) Has been cancelled
Node tests / test (push) Has been cancelled
Node tests / test-summary (push) Has been cancelled
UPSTREAM BASELINE: nextcloud/spreed v22.0.12 (без изменений)
Источник: https://github.com/nextcloud/spreed/archive/refs/tags/v22.0.12.tar.gz
С этого коммита ветка официального Nextcloud Talk отрезана (решение владельца 2026-07-06).
Все дальнейшие изменения — только наши; версии релизов: 22.0.12-f7.N.
2026-07-06 14:07:50 +00:00

37 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2025 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\SpreedCheats\Calendar;
use Sabre\VObject\UUIDUtil;
class EventGenerator {
public static function generateEvents(string $name, string $location, int $start, int $end): array {
$files = scandir(__DIR__ . '/../../calendars/');
$events = [];
$startDate = (new \DateTime())->setTimestamp($start);
$endDate = (new \DateTime())->setTimestamp($end);
foreach ($files as $file) {
if ($file === '.' || $file === '..') {
continue;
}
$calData = file_get_contents(__DIR__ . '/../../calendars/' . $file);
if ($calData === false) {
continue;
}
$interval = new \DateInterval('P1D');
$startDate->add($interval);
$endDate->add($interval);
$uid = UUIDUtil::getUUID();
$events[] = str_replace(['{{{NAME}}}', '{{{START}}}', '{{{END}}}', '{{{UID}}}', '{{{LOCATION}}}'], [$name, $startDate->format('Ymd\THis'), $endDate->format('Ymd\THis'), $uid, $location], $calData);
}
return $events;
}
}