protected function validateDatetime($value, ValidationField $field) {
        if ($value instanceof \DateTimeInterface) {
            // do nothing, we're good
        } elseif (is_string($value) && $value !== '' && !is_numeric($value)) {
            try {
                $dt = new \DateTimeImmutable($value);
                if ($dt) {
                    $value = $dt;
                } else {
                    $value = null;
                }
            } catch (\Throwable $ex) {
                $value = Invalid::value();
            }
        } elseif (is_int($value) && $value > 0) {
            try {
                $value = new \DateTimeImmutable('@'.(string)round($value));
            } catch (\Throwable $ex) {
                $value = Invalid::value();
            }
        } else {
            $value = Invalid::value();
        }

        if (Invalid::isInvalid($value)) {
            $field->addTypeError($value, 'date/time');
        }
        return $value;
    }