Skip to content

Commit d1b7600

Browse files
authored
Merge pull request #1285 from ashnazg/clock
rewording the timezone faq
2 parents 513d0ee + 8f2185a commit d1b7600

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

proposed/clock-meta.md

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -141,30 +141,24 @@ _**Note:** Order descending chronologically._
141141

142142
There are different reasons why this interface does not enforce a specific timezone.
143143

144-
For one thing there is a purely technical reason. The interface provides an explicit contract. Part of this
145-
contract is the value that is returned by the `now`-function. The only thing that currently can explicitly
146-
be enforced on the language level is, that the returned value is of type `DateTimeImmutable`. There
147-
currently is no way to enforce that this object has a certain timezone as its value. So from a language
148-
level perspective there is no way to explicitly enforce a certain timezone in the returned object.
149-
150-
On the other hand, there is also a logical reason. The explicit contract should be usable in all situations
151-
where one needs a way to retrieve the current time. And on the contract level we should not make an
152-
assumption about what the caller might need. So would the contract define that only UTC is returned, then
153-
use-cases that do require something else will have to explicitly work around that or find other ways of
154-
handling the problem, the contract tries to solve as the contract does not fit the needs. This is different
155-
from the issue of i.e., immutability which can also not be enforced on the language level but which is
156-
necessary to adhere to other calls on the contract. IN the case of the `clock`-interface there will be no
157-
other calls.
158-
159-
And most important of all, the explicit contract provided by this interface does not reduce a user’s
160-
possibilities to use an implicit contract within their application, that defines that the interface
161-
will only return `DateTimeImmutable`s with a specific timezone set. And whether that is `UTC` or reduce
162-
`Antarctica/Troll` is completely up to the user.
163-
164-
The explicit contract that is defined by the interface does not limit a user in what they are doing. It
165-
tries to solve the problem of getting the current time in a reliable way. Which view on the current time
166-
that is, is not part of the explicit contract.
167-
168-
So, all in all: This interface tries to be as open as possible while at the same time being as
169-
strict as necessary.
170-
144+
A purely _technical_ reason is that the interface itself provides an explicit contract. Part of this contract
145+
is the value returned by the `now()` method. At the _language_ level, the only thing we can enforce is that
146+
the returned value is of type `\DateTimeImmutable`. There is no way to enforce a certain timezone at the
147+
language level.
148+
149+
A _logical_ reason is that the explicit contract should be usable in all situations where one needs a way to
150+
retrieve the current time. We should not make an assumption at the _contract_ level about what the caller
151+
needs. If the contract did define that only `UTC` is returned, then use cases that require something else
152+
would have to explicitly work around the returned `UTC` timezone. This is different from an issue like
153+
immutability, which also cannot be enforced on the language level, but which is still necessary to adhere
154+
to other calls on the contract. For this `ClockInterface`, there will be no other calls.
155+
156+
Most importantly, the explicit contract provided by this interface does not _prevent_ a user from using
157+
an implicit contract alongside logic to return a `\DateTimeImmutable` with a specific timezone. Whether
158+
that is `UTC` or `Antarctica/Troll`, it is the _user_ who is in control of this.
159+
160+
The explicit contract defined by the interface does not limit a user in what they are doing. It tries to
161+
solve the problem of getting the current time in a reliable way. Whatever view on the current time that is,
162+
it is not part of the explicit contract.
163+
164+
Thus, this interface tries to be as _open as possible_, while at the same time, being as _strict as necessary_.

0 commit comments

Comments
 (0)