Skip to content
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

fix: Time::humanize() causes error with ar locale #6120

Merged
merged 2 commits into from
Jun 15, 2022

Conversation

kenjis
Copy link
Member

@kenjis kenjis commented Jun 14, 2022

Need to rebase after merging #6116

Description
Fixes #4708
Related #6116

Checklist:

  • Securely signed commits
  • [] Component(s) with PHPDoc blocks, only if necessary or adds value
  • Unit testing, with >80% coverage
  • [] User guide updated
  • Conforms to style guide

@kenjis kenjis added the bug Verified issues on the current code behavior or pull requests that will fix them label Jun 14, 2022
ErrorException : DateTime::modify(): Failed to parse time string (۲۰۱۷-۰۳-۱۰ ۰۰:۰۰:۰۰) at position 0 (�): Unexpected character
 .../CodeIgniter4/system/I18n/Time.php:96
@datamweb
Copy link
Contributor

@kenjis also had this problem for the Persian language(fa).
The problem is now solved (after 15cd4ca,)
The output is as expected.

$time = Time::parse('March 9, 2016 12:00:00', 'Asia/Tehran');
dd ($time->humanize());

$time->humanize() UTF-8 string (16) "۶ سال پیش"

Thanks

Copy link
Member

@MGatner MGatner left a comment

Choose a reason for hiding this comment

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

Looks good, don't need to re-review after rebase.

@@ -1005,7 +1005,7 @@ public function isAfter($testTime, ?string $timezone = null): bool
*/
public function humanize()
{
$now = IntlCalendar::fromDateTime(self::now($this->timezone)->toDateTimeString());
$now = IntlCalendar::fromDateTime(self::now($this->timezone));
Copy link
Member

Choose a reason for hiding this comment

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

That's kind of funny that we were using an unnecessary intermediate string to begin with 😅

@kenjis kenjis merged commit 48a07b5 into codeigniter4:develop Jun 15, 2022
@kenjis kenjis deleted the fix-Time-humanize branch June 15, 2022 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Time::humanize() does not work with ar locale
3 participants