-
Notifications
You must be signed in to change notification settings - Fork 1
Make localized DateTime formatter comparable with IntlDateFormatter #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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
|
@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 |
src/LocalizedStrftimeFormatter.php
Outdated
|
|
||
| public function formatTimestamp(string $format, \DateTimeImmutable $timestamp): string | ||
| { | ||
| $date = DateTimeImmutable::createFromInterface($timestamp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
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
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.