Make localized DateTime formatter comparable with IntlDateFormatter#5
Merged
Conversation
Migrated with '--migrate-configuration'
Because the intl extension with the IntlDateFormatter is extremely slow, we have this class. But until now, we were not quite comparable with the actual output of the intl formatter.
Using only the "type" arguments to the intl formatter, we can mimic the special localized formats (that are not a part of DateTime formatting). Only the "llll" format does not work that way, and we need a pattern to test that out. Links at the top of the file can be used to verify.
Because we compare with the v76 version, we need to skip the comparison tests if the version isn't correct
Collaborator
Author
|
@sunkan I can't see a way to bump the ICU data version to 76 for the intl comparison test. So, I think we need to keep it this way. This will fix itself when |
sunkan
reviewed
Jan 12, 2026
|
|
||
| public function formatTimestamp(string $format, \DateTimeImmutable $timestamp): string | ||
| { | ||
| $date = DateTimeImmutable::createFromInterface($timestamp); |
Collaborator
Author
There was a problem hiding this comment.
Yes, this is wrong, for sure. I think the actual problem is that the formatter interface is asking for a \DateTimeImmutable instead of \DateTimeInterface like the format() method. I will change that
Also, use DateTimeInterface instead of Immutable
Add new interface to allow keeping BC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change localized DT formatter to be comparable with IntlDateFormatter.
Because the intl extension with the IntlDateFormatter is extremely slow, we have this class.
But until now, we were not quite comparable with the actual output of the intl formatter.
So, here we at least try to be comparable, and have tests to prove so.
Note that this should be a breaking change and result in a 3.x version.