mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 02:00:51 -04:00
feat(ITimeFactory): Implement createFromFormat
Allow usage of \DateTime::createFromFormat from the ITimeFactory Signed-off-by: Micke Nordin <kano@sunet.se>
This commit is contained in:
parent
a178acfa1c
commit
42cb346efd
2 changed files with 19 additions and 0 deletions
|
|
@ -24,6 +24,17 @@ class TimeFactory implements ITimeFactory {
|
|||
$this->timezone = new \DateTimeZone('UTC');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $format
|
||||
* @param string $time
|
||||
* @param \DateTimeZone|null $timezone
|
||||
* @return \DateTime with the result of a call to \DateTime::createFromFormat()
|
||||
* @since 32.0.0
|
||||
*/
|
||||
public function createFromFormat(string $format, string $time = 'now', ?\DateTimeZone $timezone = null): \DateTime {
|
||||
return \DateTime::createFromFormat($format, $time, $timezone);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int the result of a call to time()
|
||||
* @since 8.0.0
|
||||
|
|
|
|||
|
|
@ -20,6 +20,14 @@ use Psr\Clock\ClockInterface;
|
|||
*/
|
||||
|
||||
interface ITimeFactory extends ClockInterface {
|
||||
/**
|
||||
* @param string $format
|
||||
* @param string $time
|
||||
* @param \DateTimeZone|null $timezone
|
||||
* @return \DateTime with the result of a call to \DateTime::createFromFormat()
|
||||
* @since 32.0.0
|
||||
*/
|
||||
public function createFromFormat(string $format, string $time = 'now', ?\DateTimeZone $timezone = null): \DateTime;
|
||||
/**
|
||||
* @return int the result of a call to time()
|
||||
* @since 8.0.0
|
||||
|
|
|
|||
Loading…
Reference in a new issue