Prado\Util\TSimpleDateFormatter::getMonthPattern PHP Метод

getMonthPattern() публичный Метод

public getMonthPattern ( )
    public function getMonthPattern()
    {
        if (is_int(strpos($this->pattern, 'MMMM'))) {
            return 'MMMM';
        }
        if (is_int(strpos($this->pattern, 'MMM'))) {
            return 'MMM';
        }
        if (is_int(strpos($this->pattern, 'MM'))) {
            return 'MM';
        }
        if (is_int(strpos($this->pattern, 'M'))) {
            return 'M';
        }
        return false;
    }

Usage Example

Пример #1
0
 /**
  * Returns the localized month names that depends on the month format pattern.
  * "MMMM" will return the month names, "MM" or "MMM" return abbr. month names
  * and "M" return month digits.
  * @param DateTimeFormatInfo localized date format information.
  * @return array localized month names.
  */
 protected function getLocalizedMonthNames($info)
 {
     $formatter = new TSimpleDateFormatter($this->getDateFormat());
     switch ($formatter->getMonthPattern()) {
         case 'MMM':
             return $info->getAbbreviatedMonthNames();
         case 'MM':
             $array = array();
             for ($i = 1; $i <= 12; $i++) {
                 $array[$i - 1] = $i < 10 ? '0' . $i : $i;
             }
             return $array;
         case 'M':
             $array = array();
             for ($i = 1; $i <= 12; $i++) {
                 $array[$i - 1] = $i;
             }
             return $array;
         default:
             return $info->getMonthNames();
     }
 }