Skip to content

Commit

Permalink
兼容pg更改
Browse files Browse the repository at this point in the history
  • Loading branch information
NHZEX committed Jun 2, 2023
1 parent bf3a2a4 commit b2c4ad7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/Components/pgsql/src/Model/PgModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ protected static function parseDateTime(?string $columnType, $timeAccuracy, ?flo
case 'timetz':
if ($timeAccuracy >= 1000)
{
[$usec, $sec] = explode(' ', microtime());
$sec = (int) $microTime;
$usec = $microTime - $sec; // 获取小数部分

return date('H:i:s.', (int) $sec) . (int) ((float) $usec * $timeAccuracy);
return date('H:i:s.', $sec) . (int) ((float) $usec * $timeAccuracy);
}
else
{
Expand All @@ -43,9 +44,10 @@ protected static function parseDateTime(?string $columnType, $timeAccuracy, ?flo
case 'timestamptz':
if ($timeAccuracy >= 1000)
{
[$usec, $sec] = explode(' ', microtime());
$sec = (int) $microTime;
$usec = $microTime - $sec; // 获取小数部分

return date('Y-m-d H:i:s.', (int) $sec) . (int) ((float) $usec * $timeAccuracy);
return date('Y-m-d H:i:s.', $sec) . (int) ($usec * $timeAccuracy);
}
else
{
Expand All @@ -55,7 +57,7 @@ protected static function parseDateTime(?string $columnType, $timeAccuracy, ?flo
case 'int':
case 'int2':
case 'int4':
return time();
return (int) $microTime;
case 'int8':
return (int) ($microTime * (true === $timeAccuracy ? 1000 : $timeAccuracy));
default:
Expand Down

0 comments on commit b2c4ad7

Please sign in to comment.