Skip to content

Commit

Permalink
Fix conversion of ICU 'L' symbol.
Browse files Browse the repository at this point in the history
L should not contain a leading zero.
Added a test for this too.

close yiisoft#7761
  • Loading branch information
nkovacs authored and cebe committed May 2, 2015
1 parent 3f24954 commit b31b9e2
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions framework/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Yii Framework 2 Change Log
- Bug #7603: Fixed escape characters in `FormatConverter` to work with unicode characters (maddoger, cebe)
- Bug #7656: Fixed `yii\rbac\DbManager::getRolesByUser()` and `yii\rbac\PhpManager::getRolesByUser()` to return roles only (samdark)
- Bug #7757: Fix fetching tables schema for oci and mysql when PDO::ATTR_CASE is set (nineinchnick)
- Bug #7761: Fixed formatting one digit month in date formatter using ICU format `L` (nkovacs)
- Bug #7775: Added more strict check on controller IDs when they are being used to create controller instances on Windows (Bhoft, qiangxue)
- Bug #7831: Add order when fetching database table names and constraints (nineinchnick)
- Bug #7846: Fixed `yii\base\Model` does not recognize scenario declared by rules using 'except' (klimov-paul)
Expand Down
4 changes: 2 additions & 2 deletions framework/helpers/BaseFormatConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public static function convertDateIcuToPhp($pattern, $type = 'date', $locale = n
'MMM' => 'M', // A short textual representation of a month, three letters
'MMMM' => 'F', // A full textual representation of a month, such as January or March
'MMMMM' => '', //
'L' => 'm', // Stand alone month in year
'L' => 'n', // Stand alone month in year
'LL' => 'm', // Stand alone month in year
'LLL' => 'M', // Stand alone month in year
'LLLL' => 'F', // Stand alone month in year
Expand Down Expand Up @@ -363,7 +363,7 @@ public static function convertDateIcuToJui($pattern, $type = 'date', $locale = n
'MMM' => 'M', // A short textual representation of a month, three letters
'MMMM' => 'MM', // A full textual representation of a month, such as January or March
'MMMMM' => '', //
'L' => 'mm', // Stand alone month in year
'L' => 'm', // Stand alone month in year
'LL' => 'mm', // Stand alone month in year
'LLL' => 'M', // Stand alone month in year
'LLLL' => 'MM', // Stand alone month in year
Expand Down
2 changes: 2 additions & 0 deletions tests/framework/helpers/FormatConverterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ public function testIntlOneDigitIcu()
$formatter = new Formatter(['locale' => 'en-US']);
$this->assertEquals('24.8.2014', $formatter->asDate('2014-8-24', 'php:d.n.Y'));
$this->assertEquals('24.8.2014', $formatter->asDate('2014-8-24', 'd.M.yyyy'));
$this->assertEquals('24.8.2014', $formatter->asDate('2014-8-24', 'd.L.yyyy'));
}

public function testOneDigitIcu()
{
$formatter = new Formatter(['locale' => 'en-US']);
$this->assertEquals('24.8.2014', $formatter->asDate('2014-8-24', 'php:d.n.Y'));
$this->assertEquals('24.8.2014', $formatter->asDate('2014-8-24', 'd.M.yyyy'));
$this->assertEquals('24.8.2014', $formatter->asDate('2014-8-24', 'd.L.yyyy'));
}

public function testIntlUtf8Ru()
Expand Down

0 comments on commit b31b9e2

Please sign in to comment.