/** * Return year, month or day from date * * @param integer $position */ private function getYearMonthDay($position) { $word = $this->queryManager->words[$position]['word']; if (preg_match('/^\\d{4}$/i', $word)) { return array('year' => $word); } $month = $this->queryManager->dictionary->get(RestoDictionary::MONTH, $word); if (isset($month)) { return array('month' => $month); } $number = $this->queryManager->dictionary->getNumber($word); if (is_numeric($number)) { $day = intval($number); if ($day > 0 && $day < 31) { return array('day' => $day < 10 ? '0' . $day : $day); } } /* * ISO8601 date */ if (RestoUtil::isISO8601($word)) { return $this->iso8601ToDate($word); } return null; }