protected function DateArgumentWrapper::createFromFormat in Calendar 8
2 calls to DateArgumentWrapper::createFromFormat()
- DateArgumentWrapper::createDateTime in src/
DateArgumentWrapper.php - DateArgumentWrapper::validateValue in src/
DateArgumentWrapper.php - Check if a string value is valid for this format.
File
- src/
DateArgumentWrapper.php, line 117
Class
- DateArgumentWrapper
- The DateArgumentWrapper class.
Namespace
Drupal\calendarCode
protected function createFromFormat($value) {
$format = $this
->getArgFormat();
if ($format == 'oW') {
$date = new \DateTime();
$year = (int) substr($value, 0, 4);
$month = (int) substr($value, 4, 2);
$date
->setISODate($year, $month);
}
else {
// Adds a ! character to the format so that the date is reset instead of
// using the current day info, which can lead to issues for months with
// 31 days.
$format = '!' . $this
->getArgFormat();
$date = \DateTime::createFromFormat($format, $value);
}
return $date;
}