/** * {@inheritdoc} */ public function convertToPHPValue($value, AbstractPlatform $platform) { if ($value === null) { return null; } return LocalDate::parse($value); }
/** * {@inheritdoc} */ public function expand($className, $value, array $options = []) { try { switch ($className) { case Duration::class: return Duration::parse($value); case LocalDate::class: return LocalDate::parse($value); case LocalTime::class: return LocalTime::parse($value); case LocalDateTime::class: return LocalDateTime::parse($value); case TimeZoneOffset::class: return TimeZoneOffset::parse($value); case TimeZoneRegion::class: return TimeZoneRegion::parse($value); case YearMonth::class: return YearMonth::parse($value); case ZonedDateTime::class: return ZonedDateTime::parse($value); } } catch (DateTimeParseException $e) { throw new ObjectNotConvertibleException($e->getMessage(), $e->getCode(), $e); } return null; }
/** * @todo belongs to LocalDate tests * * @dataProvider providerGetDayOfWeekFromLocalDate * * @param string $localDate The local date to test, as a string. * @param integer $dayOfWeek The day-of-week number that matches the local date. */ public function testGetDayOfWeekFromLocalDate($localDate, $dayOfWeek) { $localDate = LocalDate::parse($localDate); $dayOfWeek = DayOfWeek::of($dayOfWeek); $this->assertTrue($localDate->getDayOfWeek()->isEqualTo($dayOfWeek)); }
/** * @dataProvider providerContains * * @param string $range * @param string $date * @param boolean $contains */ public function testContains($range, $date, $contains) { $this->assertSame($contains, LocalDateRange::parse($range)->contains(LocalDate::parse($date))); }