2 namespace TYPO3\CMS\Form\Domain\Validator;
23 'element' => array(
'',
'The name of the element',
'string',
true),
24 'errorMessage' => array(
'',
'The error message',
'array',
true),
25 'format' => array(
'',
'The maximum value',
'string',
true),
45 $this->options[
'format'] === null
46 || $this->options[
'format'] ===
''
48 $this->options[
'format'] =
'%e-%m-%Y';
51 if (function_exists(
'strptime')) {
52 $parsedDate = strptime($value, $this->options[
'format']);
53 $parsedDateYear = $parsedDate[
'tm_year'] + 1900;
54 $parsedDateMonth = $parsedDate[
'tm_mon'] + 1;
55 $parsedDateDay = $parsedDate[
'tm_mday'];
56 if (!checkdate($parsedDateMonth, $parsedDateDay, $parsedDateYear)) {
59 $this->options[
'errorMessage'][0],
60 $this->options[
'errorMessage'][1],
79 $dateTimeFormat = str_replace(
80 array(
'%a',
'%A',
'%d',
'%e',
'%j',
'%b',
'%B',
'%h',
'%m',
'%y',
'%Y'),
81 array(
'D',
'l',
'd',
'j',
'z',
'M',
'F',
'M',
'm',
'y',
'Y'),
82 $this->options[
'format']
84 $dateTimeObject = date_create_from_format($dateTimeFormat, $value);
85 if ($dateTimeObject ===
false) {
88 $this->options[
'errorMessage'][0],
89 $this->options[
'errorMessage'][1],
97 if ($value !== $dateTimeObject->format($dateTimeFormat)) {
100 $this->options[
'errorMessage'][0],
101 $this->options[
'errorMessage'][1],
120 $message = str_replace(
'%format', $humanReadableDateFormat, $message);
135 $label = self::LOCALISATION_OBJECT_NAME .
'.strftime.';
137 '%A' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'A',
'form'),
138 '%a' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'a',
'form'),
139 '%d' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'd',
'form'),
140 '%e' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'e',
'form'),
141 '%B' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'B',
'form'),
142 '%b' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'b',
'form'),
143 '%m' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'm',
'form'),
144 '%Y' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'Y',
'form'),
145 '%y' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'y',
'form'),
146 '%H' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'H',
'form'),
147 '%I' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'I',
'form'),
148 '%M' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'M',
'form'),
149 '%S' => \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($label .
'S',
'form')
151 $humanReadableFormat = str_replace(array_keys($pairs), array_values($pairs), $format);
152 return $humanReadableFormat;