서버의 분턴 변경시 '정확히' 현재 턴에 비례해서 변경되도록 변경
This commit is contained in:
@@ -58,7 +58,7 @@ class TimeUtil
|
||||
return $obj->format('Y-m-d H:i:s.u');
|
||||
}
|
||||
|
||||
public static function secondsToDateTime(float $fullSeconds): \DateTime{
|
||||
public static function secondsToDateTime(float $fullSeconds, bool $isDateTimeImmutable=false): \DateTime{
|
||||
$seconds = floor($fullSeconds);
|
||||
$fraction = $fullSeconds - $seconds;
|
||||
|
||||
@@ -66,6 +66,11 @@ class TimeUtil
|
||||
$interval->s = $seconds;
|
||||
$interval->f = $fraction;
|
||||
|
||||
if($isDateTimeImmutable){
|
||||
$dateTime = new \DateTimeImmutable("@0");
|
||||
return $dateTime->add($interval);
|
||||
}
|
||||
|
||||
$dateTime = new \DateTime("@0");
|
||||
$dateTime->add($interval);
|
||||
return $dateTime;
|
||||
@@ -77,8 +82,8 @@ class TimeUtil
|
||||
return static::secondsToDateTime($fullSeconds)->diff($d0);
|
||||
}
|
||||
|
||||
public static function DateTimeToSeconds(\DateTime $dateTime): float{
|
||||
$dateBase = new \DateTime("@0");
|
||||
public static function DateTimeToSeconds(\DateTimeInterface $dateTime): float{
|
||||
$dateBase = new \DateTimeImmutable("@0");
|
||||
|
||||
return static::DateIntervalToSeconds($dateTime->diff($dateBase));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user