Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions apps/dav/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider;
use OCA\DAV\CalDAV\Reminder\NotificationProviderManager;
use OCA\DAV\CalDAV\Reminder\Notifier as NotifierCalDAV;
use OCA\DAV\CalDAV\TimezoneService;
use OCA\DAV\Capabilities;
use OCA\DAV\CardDAV\ContactsManager;
use OCA\DAV\CardDAV\Notification\Notifier as NotifierCardDAV;
use OCA\DAV\CardDAV\SyncService;
use OCA\DAV\ConfigLexicon;
use OCA\DAV\Db\PropertyMapper;
use OCA\DAV\Events\AddressBookCreatedEvent;
use OCA\DAV\Events\AddressBookDeletedEvent;
use OCA\DAV\Events\AddressBookShareUpdatedEvent;
Expand Down Expand Up @@ -83,13 +85,16 @@
use OCP\Calendar\Events\CalendarObjectRestoredEvent;
use OCP\Calendar\Events\CalendarObjectUpdatedEvent;
use OCP\Calendar\IManager as ICalendarManager;
use OCP\Calendar\ITimezoneService;
use OCP\Config\BeforePreferenceDeletedEvent;
use OCP\Config\BeforePreferenceSetEvent;
use OCP\Config\IUserConfig;
use OCP\Contacts\IManager as IContactsManager;
use OCP\DB\Events\AddMissingIndicesEvent;
use OCP\Federation\Events\TrustedServerRemovedEvent;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Group\Events\GroupDeletedEvent;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\IUserSession;
use OCP\Server;
Expand Down Expand Up @@ -233,6 +238,15 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(DeclarativeSettingsSetValueEvent::class, DavAdminSettingsListener::class);

$context->registerConfigLexicon(ConfigLexicon::class);

$context->registerService(ITimezoneService::class, function (ContainerInterface $c) {
return new TimezoneService(
$c->get(IConfig::class),
$c->get(IUserConfig::class),
$c->get(PropertyMapper::class),
$c->get(ICalendarManager::class),
);
});
}

public function boot(IBootContext $context): void {
Expand Down
3 changes: 2 additions & 1 deletion apps/dav/lib/CalDAV/TimezoneService.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
use OCA\DAV\Db\PropertyMapper;
use OCP\Calendar\ICalendar;
use OCP\Calendar\IManager;
use OCP\Calendar\ITimezoneService;
use OCP\Config\IUserConfig;
use OCP\IConfig;
use Sabre\VObject\Component\VCalendar;
use Sabre\VObject\Component\VTimeZone;
use Sabre\VObject\Reader;
use function array_reduce;

class TimezoneService {
class TimezoneService implements ITimezoneService {

public function __construct(
private IConfig $config,
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_classmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
'OCP\\Calendar\\IHandleImipMessage' => $baseDir . '/lib/public/Calendar/IHandleImipMessage.php',
'OCP\\Calendar\\IManager' => $baseDir . '/lib/public/Calendar/IManager.php',
'OCP\\Calendar\\IMetadataProvider' => $baseDir . '/lib/public/Calendar/IMetadataProvider.php',
'OCP\\Calendar\\ITimezoneService' => $baseDir . '/lib/public/Calendar/ITimezoneService.php',
'OCP\\Calendar\\Resource\\IBackend' => $baseDir . '/lib/public/Calendar/Resource/IBackend.php',
'OCP\\Calendar\\Resource\\IManager' => $baseDir . '/lib/public/Calendar/Resource/IManager.php',
'OCP\\Calendar\\Resource\\IResource' => $baseDir . '/lib/public/Calendar/Resource/IResource.php',
Expand Down
1 change: 1 addition & 0 deletions lib/composer/composer/autoload_static.php
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ class ComposerStaticInit749170dad3f5e7f9ca158f5a9f04f6a2
'OCP\\Calendar\\IHandleImipMessage' => __DIR__ . '/../../..' . '/lib/public/Calendar/IHandleImipMessage.php',
'OCP\\Calendar\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/IManager.php',
'OCP\\Calendar\\IMetadataProvider' => __DIR__ . '/../../..' . '/lib/public/Calendar/IMetadataProvider.php',
'OCP\\Calendar\\ITimezoneService' => __DIR__ . '/../../..' . '/lib/public/Calendar/ITimezoneService.php',
'OCP\\Calendar\\Resource\\IBackend' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IBackend.php',
'OCP\\Calendar\\Resource\\IManager' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IManager.php',
'OCP\\Calendar\\Resource\\IResource' => __DIR__ . '/../../..' . '/lib/public/Calendar/Resource/IResource.php',
Expand Down
21 changes: 21 additions & 0 deletions lib/public/Calendar/ITimezoneService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

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

namespace OCP\Calendar;

/**
* The timezone service can be used to conveniently get a user's timezone string
*
* @since 34.0.0
*/
interface ITimezoneService {
public function getUserTimezone(string $userId): ?string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like IDateTimeZone::getTimeZone

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, it's a bit more extensive than getTimeZone


public function getDefaultTimezone(): string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doing the same thing as IDateTimeZone::getDefaultTimeZone

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, maybe I can unify the interface.

}
Loading