Hi
Note: When replying on this list, please keep your reply below the
quoted parts and cut the quote to a minimum. And please try to reply to
the fit appropriate email to keep the threading from working well (see
the thread view at the bottom of
https://news-web.php.net/php.internals/132612), in the Gmail web
interface you can do that by using the Reply button on the email itself,
instead of the big box at the bottom.
On 2026-09-23 22:16, Théo Attali wrote:
The RFC specifies nanosecond precision for Time\Instant, but it is not
clear whether toIso8601DateTimeString() preserves that precision in its
output. Could the RFC clarify the fractional-second format and whether
an optional precision argument is supported?
As the RFC notes, the ISO-8601 representation is the universal one. It
therefore keeps full nanosecond precision. I clarified that in the doc
comment of the stub after having made the executive decision that it
will omit the fractional part if it is zero.
No precision argument is supported, and I don't think it would be a good
idea doing that as part of the “presentation layer”. Cutting off the
fractional part is possible using
$instant->sub(Duration::fromNanoseconds($instant->getNanoseconds())),
which while a mouthful would be an explicit action. I can imagine adding
a `->truncateTo()` method in the future, but that one will require some
design as to how to specify the the desired precision in a useful way
without opening up footguns.
Best regards
Tim Düsterhus