Commit 0995a740 by Erik_r

Refactored formatter class #2359 which works with or without intl extension. Use…

Refactored formatter class #2359 which works with or without intl extension. Use PHP format patterns alsow with intl. Class is compatible with previous version.
parent ebf0cb55
......@@ -4,6 +4,7 @@ Yii Framework 2 Change Log
2.0.0-rc under development
--------------------------
- Enh #2359: Refactored formatter class. One class with or without intl extension and PHP format pattern as standard. (Erik_r)
- Bug #1263: Fixed the issue that Gii and Debug modules might be affected by incompatible asset manager configuration (qiangxue)
- Bug #2563: Theming is not working if the path map of the theme contains ".." or "." in the paths (qiangxue)
- Bug #2801: Fixed the issue that GridView gets footer content before data cells content (ElisDN)
......
<?php
namespace guggach\helpers;
/**
* International format definitions for decimal separator, thousand separator, dates,
* times and datetimes.
*
* Is only used if php extension isn't loaded. Otherwise the official ICU standard is
* used.
*
* Returns an array per local settings. Set the option 'language' => 'de-CH' in yii
* config file.
*
* Each language has xxx elements in their array like:
* [0] = decimal separator ('.')
* [1] = thousand separator (',')
* [2] = date short ('y-m-d')
* [3] = date medium ('Y-m-d')
* [4] = date long ('F j, Y')
* [5] = date full ('l, F j, Y')
* [6] = time short ('H:i')
* [7] = time medium ('H:i:s')
* [8] = time long ('g:i:sA')
* [9] = time full ('g:i:sA T')
* [10] = datetime short ('y-m-d H:i')
* [11] = datetime medium ('Y-m-d H:i:s')
* [12] = datetime long ('F j, Y g:i:sA')
* [13] = datetime full ('l, F j, Y g:i:sA T')
* [14] = currency code
*
* @author Erik Ruedin <e.ruedin@guggach.com>
* @version 0.1
*/
Class FormatDefs{
static function definition($local) {
$localDef = [
'en-US' =>
['.', ',', 'm/d/y', 'm/d/Y', 'F j, Y', 'l, F j, Y', 'H:i', 'H:i:s', 'g:i:sA', 'g:i:sA T', 'm/d/y H:i', 'm/d/Y H:i:s', 'F j, Y g:i:sA', 'l, F j, Y g:i:sA T', 'USD' ],
'de-CH' =>
['.', '\'', 'd.m.y', 'd.m.Y', 'j. F Y', 'l, j. F Y', 'H:i', 'H:i:s', 'G:i:s', 'G:i:s T', 'd.m.y H:i', 'd.m.Y H:i:s', 'F j, Y g:i:sA', 'l, F j, Y g:i:sA T', 'CHF' ],
'de-DE' =>
[',', '.', 'd.m.y', 'd.m.Y', 'j. F Y', 'l, j. F Y', 'H:i', 'H:i:s', 'G:i:s', 'G:i:s T', 'd.m.y H:i', 'd.m.Y H:i:s', 'F j, Y g:i:sA', 'l, F j, Y g:i:sA T', 'EUR' ],
];
if (isset($localDef[$local])){
return $localDef[$local];
} else{
return [];
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment