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

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

    public function getDayMonthYearOrdering()
    {
        $ordering = array();
        if (is_int($day = strpos($this->pattern, 'd'))) {
            $ordering['day'] = $day;
        }
        if (is_int($month = strpos($this->pattern, 'M'))) {
            $ordering['month'] = $month;
        }
        if (is_int($year = strpos($this->pattern, 'yy'))) {
            $ordering['year'] = $year;
        }
        asort($ordering);
        return array_keys($ordering);
    }

Usage Example

Пример #1
0
 /**
  * Renders the calendar drop down list depending on the DateFormat pattern.
  * @param THtmlWriter the Html writer to render the drop down lists.
  * @param array the current selected date
  */
 protected function renderCalendarSelections($writer, $date)
 {
     $formatter = new TSimpleDateFormatter($this->getDateFormat());
     foreach ($formatter->getDayMonthYearOrdering() as $type) {
         if ($type == 'day') {
             $this->renderCalendarDayOptions($writer, $date['mday']);
         } elseif ($type == 'month') {
             $this->renderCalendarMonthOptions($writer, $date['mon']);
         } elseif ($type == 'year') {
             $this->renderCalendarYearOptions($writer, $date['year']);
         }
     }
 }