서버의 분턴 변경시 '정확히' 현재 턴에 비례해서 변경되도록 변경

This commit is contained in:
2018-09-16 04:38:06 +09:00
parent 71d2102c4c
commit b10cf6e461
2 changed files with 25 additions and 37 deletions
+8 -3
View File
@@ -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));
}