Skip to content

Commit

Permalink
Merge pull request #3277 from mhsdesign/task/fixIntegerConverterWhenC…
Browse files Browse the repository at this point in the history
…onvertingDateTime

TASK: Ensure `IntegerConverter` converts DateTime to unix time stamp as int
  • Loading branch information
mhsdesign committed Jan 25, 2024
2 parents 306a13c + c70601a commit c0b8578
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class IntegerConverter extends AbstractTypeConverter
public function convertFrom($source, $targetType, array $convertedChildProperties = [], PropertyMappingConfigurationInterface $configuration = null)
{
if ($source instanceof \DateTimeInterface) {
return $source->format('U');
return (int)$source->format('U');
}

if ($source === null || $source === '') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function convertFromCastsStringToInteger()
public function convertFromCastsDateTimeToInteger()
{
$dateTime = new \DateTime();
self::assertSame($dateTime->format('U'), $this->converter->convertFrom($dateTime, 'integer'));
self::assertSame((int)$dateTime->format('U'), $this->converter->convertFrom($dateTime, 'integer'));
}

/**
Expand Down

0 comments on commit c0b8578

Please sign in to comment.