Skip to content

Commit f760c05

Browse files
author
Greg Bowler
authored
Fix microseconds (#43)
* test: implement unit tests * refactor: remove unused getClass function * test: upgrade phpunit * fix: retain microseconds of datetime closes #42
1 parent 17807fb commit f760c05

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/NullableTypeSafeGetter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ public function getBool(string $name):?bool {
2626
public function getDateTime(string $name):?DateTimeInterface {
2727
return $this->getNullableType(
2828
$name,
29-
function(string|int|DateTimeInterface $value) {
29+
function(string|int|float|DateTimeInterface $value) {
3030
if($value instanceof DateTimeInterface) {
3131
return $value;
3232
}
3333

3434
if(is_numeric($value)) {
35-
$dt = new DateTimeImmutable();
36-
return $dt->setTimestamp($value);
35+
return new DateTimeImmutable("@$value");
3736
}
37+
3838
return new DateTimeImmutable($value);
3939
}
4040
);

0 commit comments

Comments
 (0)