You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
740 B
PHP

<?php
/**
* @internal
*/
class SageParsersDateTime implements SageParserInterface
{
public function replacesAllOtherParsers()
{
return true;
}
public function parse(&$variable, $varData)
{
if (! $variable instanceof DateTimeInterface) {
return false;
}
$format = 'Y-m-d H:i:s';
$ms = $variable->format('u');
if (rtrim($ms, '0')) {
$format .= '.' . $ms;
} else {
$format .= '.0';
}
if ($variable->getTimezone()->getLocation()) {
$format .= ' e';
}
$format .= ' (P)';
$varData->value = $variable->format($format);
$varData->type = get_class($variable);
}
}