feat: addTurn, subTurn, cutTurn에서 VarTurn60 버전 호환

This commit is contained in:
2025-10-29 16:01:23 +00:00
parent 76ea61f751
commit acd73fc63e
+24
View File
@@ -923,6 +923,13 @@ function banner()
function addTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
{
if($turnterm < 0){
if($turnterm == -60){
return VarTurn60::fromDatetime(new \DateTimeImmutable(($date)))->addTurn($turn )->toDateStr($withFraction);
}
throw new \Exception("InvalidTurnTerm".$turnterm);
}
$date = new \DateTime($date);
$target = $turnterm * $turn;
$date->add(new \DateInterval("PT{$target}M"));
@@ -934,6 +941,13 @@ function addTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
function subTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
{
if($turnterm < 0){
if($turnterm == -60){
return VarTurn60::fromDatetime(new \DateTimeImmutable(($date)))->addTurn($turn * -1)->toDateStr($withFraction);
}
throw new \Exception("InvalidTurnTerm".$turnterm);
}
$date = new \DateTime($date);
$target = $turnterm * $turn;
$date->sub(new \DateInterval("PT{$target}M"));
@@ -945,6 +959,14 @@ function subTurn($date, int $turnterm, int $turn = 1, bool $withFraction = true)
function cutTurn($date, int $turnterm, bool $withFraction = true)
{
if($turnterm < 0){
if($turnterm == -60){
[$baseDate, ] = VarTurn60::fromDatetime(new \DateTimeImmutable(($date)))->cutTurn($withFraction);
return $baseDate;
}
throw new \Exception("InvalidTurnTerm".$turnterm);
}
$date = new \DateTime($date);
$baseDate = new \DateTime($date->format('Y-m-d'));
@@ -963,6 +985,8 @@ function cutTurn($date, int $turnterm, bool $withFraction = true)
function cutDay($date, int $turnterm, bool $withFraction = true)
{
assert($turnterm > 0);
$date = new \DateTime($date);
$baseDate = new \DateTime($date->format('Y-m-d'));