Skip to content

Commit 7ba3dda

Browse files
committed
fix: DatetimeCast handles string input to prevent DataConverter crash
1 parent 8525cee commit 7ba3dda

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎system/DataCaster/Cast/DatetimeCast.php‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,15 @@ public static function set(
5151
array $params = [],
5252
?object $helper = null,
5353
): string {
54-
if (! $value instanceof Time) {
54+
if (is_string($value)) {
55+
try {
56+
$value = Time::parse($value);
57+
} catch (\Exception $e) {
58+
self::invalidTypeValueError($value);
59+
}
60+
}
61+
62+
if (! $value instanceof \DateTimeInterface) {
5563
self::invalidTypeValueError($value);
5664
}
5765

0 commit comments

Comments
 (0)