mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-14 04:14:36 +02:00
Use a better exception format for UTCDateTimeType
This commit is contained in:
parent
1830e9da3d
commit
4d927c5870
1 changed files with 6 additions and 1 deletions
|
@ -28,6 +28,7 @@ use DateTimeZone;
|
||||||
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||||
use Doctrine\DBAL\Types\ConversionException;
|
use Doctrine\DBAL\Types\ConversionException;
|
||||||
use Doctrine\DBAL\Types\DateTimeType;
|
use Doctrine\DBAL\Types\DateTimeType;
|
||||||
|
use Doctrine\DBAL\Types\Exception\InvalidFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This DateTimeType all dates to UTC, so it can be later used with the timezones.
|
* This DateTimeType all dates to UTC, so it can be later used with the timezones.
|
||||||
|
@ -83,7 +84,11 @@ class UTCDateTimeType extends DateTimeType
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$converted) {
|
if (!$converted) {
|
||||||
throw new ConversionException("Failed to convert PHP value to a DateTime object.");
|
throw InvalidFormat::new(
|
||||||
|
$value,
|
||||||
|
static::class,
|
||||||
|
$platform->getDateTimeFormatString(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $converted;
|
return $converted;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue