File tree Expand file tree Collapse file tree 2 files changed +44
-0
lines changed
developer_manual/digging_deeper Expand file tree Collapse file tree 2 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -44,3 +44,4 @@ Digging deeper
4444 deadlock
4545 phonenumberutil
4646 out_of_office
47+ time
Original file line number Diff line number Diff line change 1+ =================
2+ Working with time
3+ =================
4+
5+ You can inject the ``\OCP\AppFramework\Utility\ITimeFactory `` which wraps commonly used time functions for easier testability.
6+
7+ Methods
8+ -------
9+
10+ The factory extends the ``\PSR\Clock\ClockInterface `` with the following methods:
11+
12+ .. code-block :: php
13+
14+ <?php
15+
16+ /**
17+ * @return int the result of a call to time()
18+ * @since 8.0.0
19+ */
20+ public function getTime(): int;
21+
22+ /**
23+ * @param string $time
24+ * @param \DateTimeZone|null $timezone
25+ * @return \DateTime
26+ * @since 15.0.0
27+ */
28+ public function getDateTime(string $time = 'now', \DateTimeZone $timezone = null): \DateTime;
29+
30+ /**
31+ * @param \DateTimeZone $timezone
32+ * @return static
33+ * @since 26.0.0
34+ */
35+ public function withTimeZone(\DateTimeZone $timezone): static;
36+
37+ /**
38+ * @param string|null $timezone
39+ * @return \DateTimeZone Requested timezone if provided, UTC otherwise
40+ * @throws \Exception
41+ * @since 29.0.0
42+ */
43+ public function getTimeZone(?string $timezone = null): \DateTimeZone;
You can’t perform that action at this time.
0 commit comments