Skip to content

Conversation

@bix0r
Copy link
Collaborator

@bix0r bix0r commented Dec 18, 2025

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.

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.
@bix0r bix0r requested a review from sunkan December 18, 2025 13:06
Because we compare with the v76 version, we need to skip the comparison tests if the version isn't correct
@bix0r
Copy link
Collaborator Author

bix0r commented Dec 19, 2025

@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 ubuntu:latest runner is running ubuntu 26.04. Looks like that will use v78.


public function formatTimestamp(string $format, \DateTimeImmutable $timestamp): string
{
$date = DateTimeImmutable::createFromInterface($timestamp);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants