Skip to content

Commit

Permalink
Fix #17604 problem formatting milliseconds using i18nFormat in 4.x (#…
Browse files Browse the repository at this point in the history
…17605)

* Fix #17604 problem formatting milliseconds using i18nFormat
  • Loading branch information
freefri committed Mar 4, 2024
1 parent a28d658 commit fe40e4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/I18n/DateFormatTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ protected function _formatObject($date, $format, ?string $locale): string
static::$_formatters[$key] = $formatter;
}

return static::$_formatters[$key]->format($date->format('U'));
return static::$_formatters[$key]->format($date);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/TestCase/I18n/TimeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,12 @@ public function testI18nFormat(string $class): void
$result = $time->i18nFormat(IntlDateFormatter::FULL, 'Asia/Tokyo', 'ja-JP@calendar=japanese');
$expected = '平成22年1月14日木曜日 22時59分28秒 日本標準時';
$this->assertTimeFormat($expected, $result);

// Test with milliseconds
$timeMillis = new FrozenTime('2014-07-06T13:09:01.523000+00:00');
$result = $timeMillis->i18nFormat("yyyy-MM-dd'T'HH':'mm':'ss.SSSxxx", null, 'en-US');
$expected = '2014-07-06T13:09:01.523+00:00';
$this->assertSame($expected, $result);
}

/**
Expand Down

0 comments on commit fe40e4f

Please sign in to comment.