Intl recommendation + PHP81_BC\strftime + Symfony ICU Polyfill#69
Intl recommendation + PHP81_BC\strftime + Symfony ICU Polyfill#69kamilwylegala merged 4 commits intomasterfrom
PHP81_BC\strftime + Symfony ICU Polyfill#69Conversation
|
Hey! I see that you only updated the |
|
Hi! Sorry to chime in so late, but regarding updating use of If this MR is going to go that far, I'm wondering if it could be made to be less of a breaking change by preferring Maybe something like this in protected static function _strftime($format, $timestamp) {
// $format = strftime($format, $timestamp);
if (function_exists('datefmt_create')) {
$format = datefmt_create(/* args */);
} else if (class_exists('IntlDateFormatter')) {
$format = new IntlDateFormatter(/* args */);
} else {
// fallback to date() instead of strftime()
$format = date($format, $timestamp);
}
// ...
// ...the rest of _strftime()
// ...
}That strikes me as a bit friendlier approach for anyone who may have difficulty installing |
|
@pbarabe @diegosurita Thank you for your comments. Maybe we could use Symfony's polyfill for ithttps://github.com/symfony/polyfill-intl-icu ? What do you think? |
|
Hmmm, so looking into this a bit more, I realize the code I suggested previously won't really work (not as suggested, anyway), since PHP's I think that adding But since the real problem appears to be that
I wonder if another path worth considering would be to simply deprecate the entire |
Nevermind this. I just looked through the commit history of @diegosurita's PR #64 and saw where he'd started to refactor by using |
|
Hello guys!
@kamilwylegala Yeah, we definitely could use that polyfill. |
OK, I will work on extending this branch next week. 😁 |
df30c07 to
ed352d8
Compare
ed352d8 to
2a17d1c
Compare
PHP81_BC\strftime + Symfony ICU Polyfill
9b1b4d8 to
40a8156
Compare
|
@diegosurita Done ✔️ I had to also install |
| } | ||
| if (!$valid) { | ||
| $format = mb_convert_encoding($format, 'UTF-8', 'ISO-8859-1'); | ||
| $formatted = mb_convert_encoding($format, 'UTF-8', 'ISO-8859-1'); |
There was a problem hiding this comment.
Hi @kamilwylegala, I'm curious about the change in this line. I see that instead of updating the value of $format, you're instantiating a new variable $formatted. But it doesn't seem like $formatted gets used anywhere, and then the method just returns $format. What am I missing?
There was a problem hiding this comment.
Good catch @pbarabe ! I initially experimented with mimicking the behavior of strftime on my own and after that I discovered PHP81_BC/strftime - this is a leftover. I will revert this code. Thanks!
There was a problem hiding this comment.
Oh good deal - glad I mentioned it. And thanks for finding an easy(ish) solution!
|
Looks like |
40a8156 to
07cadc0
Compare
Thank you! I will soon merge this PR 😊 |
07cadc0 to
4332b5f
Compare
|
Thank you @diegosurita @pbarabe Merged! |
No description provided.