function DateCaster::castDateTime
File
-
vendor/
symfony/ var-dumper/ Caster/ DateCaster.php, line 27
Class
- DateCaster
- Casts DateTimeInterface related classes to array representation.
Namespace
Symfony\Component\VarDumper\CasterCode
public static function castDateTime(\DateTimeInterface $d, array $a, Stub $stub, bool $isNested, int $filter) : array {
$prefix = Caster::PREFIX_VIRTUAL;
$location = $d->getTimezone() ? $d->getTimezone()
->getLocation() : null;
$fromNow = (new \DateTimeImmutable())->diff($d);
$title = $d->format('l, F j, Y') . "\n" . self::formatInterval($fromNow) . ' from now' . ($location ? $d->format('I') ? "\nDST On" : "\nDST Off" : '');
unset($a[Caster::PREFIX_DYNAMIC . 'date'], $a[Caster::PREFIX_DYNAMIC . 'timezone'], $a[Caster::PREFIX_DYNAMIC . 'timezone_type']);
$a[$prefix . 'date'] = new ConstStub(self::formatDateTime($d, $location ? ' e (P)' : ' P'), $title);
$stub->class .= $d->format(' @U');
return $a;
}