aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/AppFramework/Utility/TimeFactory.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/AppFramework/Utility/TimeFactory.php')
-rw-r--r--lib/private/AppFramework/Utility/TimeFactory.php35
1 files changed, 11 insertions, 24 deletions
diff --git a/lib/private/AppFramework/Utility/TimeFactory.php b/lib/private/AppFramework/Utility/TimeFactory.php
index 2763751132c..0584fd05ef9 100644
--- a/lib/private/AppFramework/Utility/TimeFactory.php
+++ b/lib/private/AppFramework/Utility/TimeFactory.php
@@ -1,30 +1,10 @@
<?php
declare(strict_types=1);
-
/**
- * @copyright Copyright (c) 2022, Joas Schilling <coding@schilljs.com>
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\AppFramework\Utility;
@@ -60,7 +40,7 @@ class TimeFactory implements ITimeFactory {
* @since 15.0.0
* @deprecated 26.0.0 {@see ITimeFactory::now()}
*/
- public function getDateTime(string $time = 'now', \DateTimeZone $timezone = null): \DateTime {
+ public function getDateTime(string $time = 'now', ?\DateTimeZone $timezone = null): \DateTime {
return new \DateTime($time, $timezone);
}
@@ -73,4 +53,11 @@ class TimeFactory implements ITimeFactory {
return $clone;
}
+
+ public function getTimeZone(?string $timezone = null): \DateTimeZone {
+ if ($timezone !== null) {
+ return new \DateTimeZone($timezone);
+ }
+ return $this->timezone;
+ }
}