getMonthPattern() public method

public getMonthPattern ( )
Beispiel #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();
     }
 }