| 1 | <?php |
||
| 19 | class MomentFormatConverter |
||
| 20 | { |
||
| 21 | /** |
||
| 22 | * This defines the mapping between PHP ICU date format (key) and moment.js date format (value) |
||
| 23 | * For ICU formats see http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax |
||
| 24 | * For Moment formats see http://momentjs.com/docs/#/displaying/format/. |
||
| 25 | * |
||
| 26 | * @var array |
||
| 27 | */ |
||
| 28 | private static $formatConvertRules = [ |
||
| 29 | // year |
||
| 30 | 'yyyy' => 'YYYY', 'yy' => 'YY', 'y' => 'YYYY', |
||
| 31 | // day |
||
| 32 | 'dd' => 'DD', 'd' => 'D', |
||
| 33 | // day of week |
||
| 34 | 'EE' => 'ddd', 'EEEEEE' => 'dd', |
||
| 35 | // timezone |
||
| 36 | 'ZZZZZ' => 'Z', 'ZZZ' => 'ZZ', |
||
| 37 | // letter 'T' |
||
| 38 | '\'T\'' => 'T', |
||
| 39 | ]; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * Returns associated moment.js format. |
||
| 43 | */ |
||
| 44 | 2 | public function convert(string $format): string |
|
| 48 | } |
||
| 49 |