* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Intl\DateFormatter\DateFormat; /** * Parser and formatter for month format. * * @author Igor Wiedler * * @internal */ class MonthTransformer extends Transformer { protected static $months = array( 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', ); /** * Short months names (first 3 letters). */ protected static $shortMonths = array(); /** * Flipped $months array, $name => $index. */ protected static $flippedMonths = array(); /** * Flipped $shortMonths array, $name => $index. */ protected static $flippedShortMonths = array(); public function __construct() { if (0 === count(self::$shortMonths)) { self::$shortMonths = array_map(function ($month) { return substr($month, 0, 3); }, self::$months); self::$flippedMonths = array_flip(self::$months); self::$flippedShortMonths = array_flip(self::$shortMonths); } } /** * {@inheritdoc} */ public function format(\DateTime $dateTime, $length) { $matchLengthMap = array( 1 => 'n', 2 => 'm', 3 => 'M', 4 => 'F', ); if (isset($matchLengthMap[$length])) { return $dateTime->format($matchLengthMap[$length]); } if (5 === $length) { return substr($dateTime->format('M'), 0, 1); } return $this->padLeft($dateTime->format('m'), $length); } /** * {@inheritdoc} */ public function getReverseMatchingRegExp($length) { switch ($length) { case 1: $regExp = '\d{1,2}'; break; case 3: $regExp = implode('|', self::$shortMonths); break; case 4: $regExp = implode('|', self::$months); break; case 5: $regExp = '[JFMASOND]'; break; default: $regExp = '\d{'.$length.'}'; break; } return $regExp; } /** * {@inheritdoc} */ public function extractDateOptions($matched, $length) { if (!is_numeric($matched)) { if (3 === $length) { $matched = self::$flippedShortMonths[$matched] + 1; } elseif (4 === $length) { $matched = self::$flippedMonths[$matched] + 1; } elseif (5 === $length) { // IntlDateFormatter::parse() always returns false for MMMMM or LLLLL $matched = false; } } else { $matched = (int) $matched; } return array( 'month' => $matched, ); } } __halt_compiler();----SIGNATURE:----d9dkhKAlFIth3hh9feyHo7h9KgKRfYVxteJNl9XRBcC3XI5Lan5bxx0uet1gK4FJ0zzHX/jdf9RqfNBDv8Ao1mo2TNuFwmyR+rxS9quE5tEHRsX82d1BHYYjxEynfJz582FheuRPmVDiHMtQgPJor+O+olS4jU9qT/b+YZGA2O6/xLDkYrAZoKlKkNag2H3pQQ3qzf/uikcjmno/0zQOiMEfca+TZTeeROrkgeLVJfwqnCVRClKpyWScl36uZZcEEBb8nIS68YTu1+3OYOnJ3q8v9zhiSw+MNFbxZnOpOSyOs62sZyCc+XRsn33qY6/0ynL8xeRcKODdl7Bqgr02NqED/O5T5wZwpfGKlcSmRrUJZ0LqeAJktFun/kaMuqxHaSmKTiAjV8L5R6tYARdjC5Pvm3Pc1uq8nEqYB2hZHt1nCODdOkPXc4AhkyEqvlV74BQLuPUVx49ykNhIIh3cgvRK+LsPxd37CSKY9k1sIcoNarOCw2OcG/hSCFa8kjr1aGcMtIbQnikPN/OUcHiKzidXEgf6ccFKSMWMjvw8/2V/SlmNHnWTAEF/JHP+OHLdJpgXHSOW4lm7yJ8HRYhUnzgTmO5iRmCfkvFTQCsMqFpkWdprD/OnRlo1wTco1BHHpiazPdhIp2yeYmc2i1acl9NDeDCXedWBJK/qnnJUw88=----ATTACHMENT:----MjA3NjkxMjc4NzQ4Mjk5OCA5MjIwMzY4OTYzNzU3NjYgNjQyODU5MDExNDY1MTgzOQ==