Skip to content

Commit 7d0c5d5

Browse files
authored
Merge pull request #1257 from heiglandreas/addReasonsNotToConvertToUtc
Add answer to a recurring question re UTC
2 parents a1a0674 + dd4ae5e commit 7d0c5d5

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

proposed/clock-meta.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,37 @@ This document stems from the work of many people in previous years, we recognize
137137

138138
*
139139
_**Note:** Order descending chronologically._
140+
141+
## 9. FAQ
142+
143+
### Why not simply use UTC?
144+
145+
There are different reasons why this interface does not enforce a specific timezone.
146+
147+
For one thing there is a purely technical reason. The interface provides an explicit contract. Part of this
148+
contract is the value that is returned by the `now`-function. The only thing that currently can explicitly
149+
be enforced on the language level is, that the returned value is of type `DateTimeImmutable`. There
150+
currently is no way to enforce that this object has a certain timezone as its value. So from a language
151+
level perspective there is no way to explicitly enforce a certain timezone in the returned object.
152+
153+
On the other hand, there is also a logical reason. The explicit contract should be usable in all situations
154+
where one needs a way to retrieve the current time. And on the contract level we should not make an
155+
assumption about what the caller might need. So would the contract define that only UTC is returned, then
156+
use-cases that do require something else will have to explicitly work around that or find other ways of
157+
handling the problem, the contract tries to solve as the contract does not fit the needs. This is different
158+
from the issue of i.e., immutability which can also not be enforced on the language level but which is
159+
necessary to adhere to other calls on the contract. IN the case of the `clock`-interface there will be no
160+
other calls.
161+
162+
And most important of all, the explicit contract provided by this interface does not reduce a user’s
163+
possibilities to use an implicit contract within their application, that defines that the interface
164+
will only return `DateTimeImmutable`s with a specific timezone set. And whether that is `UTC` or reduce
165+
`Antarctica/Troll` is completely up to the user.
166+
167+
The explicit contract that is defined by the interface does not limit a user in what they are doing. It
168+
tries to solve the problem of getting the current time in a reliable way. Which view on the current time
169+
that is, is not part of the explicit contract.
170+
171+
So, all in all: This interface tries to be as open as possible while at the same time being as
172+
strict as necessary.
173+

0 commit comments

Comments
 (0)