Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class MomentJs
- {
- static public $replacements = [
- 'y' => 'Y',
- 'yy' => 'YY',
- 'yyy' => 'YYY',
- 'yyyy' => 'YYYY',
- 'yyyyy' => 'YYYY',
- 'L' => 'M',
- 'LL' => 'MM',
- 'LLL' => 'MMM',
- 'LLLL' => 'MMMM',
- 'd' => 'D',
- 'dd' => 'DD',
- 'D' => 'DDD',
- 'DD' => 'DDDD',
- 'E' => 'ddd',
- 'EE' => 'ddd',
- 'EEE' => 'ddd',
- 'e' => 'd',
- 'ee' => 'd',
- 'eee' => 'ddd',
- 'a' => 'A',
- 'k' => 'H',
- 'kk' => 'HH',
- 'K' => 'h',
- 'KK' => 'hh'
- ];
- static public function ldlmToMoment ($ldlmPattern)
- {
- foreach (array_reverse(self::$replacements) as $ldlm => $moment) {
- $short = substr($ldlm, 0, 1);
- $ldlmPattern = preg_replace("`(?:(?!^$short)|^)($ldlm)(?:(?!^$short)|$)`", $moment, $ldlmPattern);
- }
- return $ldlmPattern;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement