2014-12-20 09:52:25 -05:00
|
|
|
<?php
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2018-01-13 08:00:51 -05:00
|
|
|
declare(strict_types=1);
|
2019-12-03 13:57:53 -05:00
|
|
|
|
2014-12-20 09:52:25 -05:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-12-20 09:52:25 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCP\AppFramework\Utility;
|
|
|
|
|
|
2022-12-22 14:09:25 -05:00
|
|
|
use Psr\Clock\ClockInterface;
|
|
|
|
|
|
2014-12-20 09:52:25 -05:00
|
|
|
/**
|
2022-12-22 14:09:25 -05:00
|
|
|
* Use this to get a timestamp or DateTime object in code to remain testable
|
|
|
|
|
*
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 8.0.0
|
2023-10-11 06:14:41 -04:00
|
|
|
* @since 27.0.0 Extends the \Psr\Clock\ClockInterface interface
|
2022-12-22 14:09:25 -05:00
|
|
|
* @ref https://www.php-fig.org/psr/psr-20/#21-clockinterface
|
2014-12-20 09:52:25 -05:00
|
|
|
*/
|
2022-12-22 14:09:25 -05:00
|
|
|
|
|
|
|
|
interface ITimeFactory extends ClockInterface {
|
2014-12-20 09:52:25 -05:00
|
|
|
/**
|
|
|
|
|
* @return int the result of a call to time()
|
2015-04-16 11:00:08 -04:00
|
|
|
* @since 8.0.0
|
2014-12-20 09:52:25 -05:00
|
|
|
*/
|
2018-10-09 09:24:28 -04:00
|
|
|
public function getTime(): int;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $time
|
2022-12-22 14:09:25 -05:00
|
|
|
* @param \DateTimeZone|null $timezone
|
2018-10-09 09:24:28 -04:00
|
|
|
* @return \DateTime
|
|
|
|
|
* @since 15.0.0
|
|
|
|
|
*/
|
2024-03-28 11:13:19 -04:00
|
|
|
public function getDateTime(string $time = 'now', ?\DateTimeZone $timezone = null): \DateTime;
|
2022-12-22 14:09:25 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param \DateTimeZone $timezone
|
|
|
|
|
* @return static
|
|
|
|
|
* @since 26.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function withTimeZone(\DateTimeZone $timezone): static;
|
2023-11-06 06:09:01 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string|null $timezone
|
|
|
|
|
* @return \DateTimeZone Requested timezone if provided, UTC otherwise
|
|
|
|
|
* @throws \Exception
|
|
|
|
|
* @since 29.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getTimeZone(?string $timezone = null): \DateTimeZone;
|
2014-12-20 09:52:25 -05:00
|
|
|
}
|