diff options
author | Joas Schilling <coding@schilljs.com> | 2018-10-09 15:24:28 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2018-10-09 15:38:31 +0200 |
commit | 840dd4b39c4dbcc5518f1e64ee9795085e76caad (patch) | |
tree | b7a5499627b79b32679e612323056b98d3c1880b /lib/private/AppFramework/Utility | |
parent | 877823eb9dc08f0675bb1183d35cbb1918348712 (diff) | |
download | nextcloud-server-840dd4b39c4dbcc5518f1e64ee9795085e76caad.tar.gz nextcloud-server-840dd4b39c4dbcc5518f1e64ee9795085e76caad.zip |
Allow to inject/mock `new \DateTime()` similar to time()
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/private/AppFramework/Utility')
-rw-r--r-- | lib/private/AppFramework/Utility/TimeFactory.php | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/private/AppFramework/Utility/TimeFactory.php b/lib/private/AppFramework/Utility/TimeFactory.php index fc3bf72609f..4526f9b1abb 100644 --- a/lib/private/AppFramework/Utility/TimeFactory.php +++ b/lib/private/AppFramework/Utility/TimeFactory.php @@ -37,9 +37,18 @@ class TimeFactory implements ITimeFactory { /** * @return int the result of a call to time() */ - public function getTime() : int { + public function getTime(): int { return time(); } + /** + * @param string $time + * @param \DateTimeZone $timezone + * @return \DateTime + * @since 15.0.0 + */ + public function getDateTime(string $time = 'now', \DateTimeZone $timezone = null): \DateTime { + return new \DateTime($time, $timezone); + } } |