diff --git a/lib/private/AppFramework/Utility/TimeFactory.php b/lib/private/AppFramework/Utility/TimeFactory.php index 0584fd05ef9..2f6f081935a 100644 --- a/lib/private/AppFramework/Utility/TimeFactory.php +++ b/lib/private/AppFramework/Utility/TimeFactory.php @@ -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 diff --git a/lib/public/AppFramework/Utility/ITimeFactory.php b/lib/public/AppFramework/Utility/ITimeFactory.php index cd63b94dee3..4d823b54efa 100644 --- a/lib/public/AppFramework/Utility/ITimeFactory.php +++ b/lib/public/AppFramework/Utility/ITimeFactory.php @@ -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