From acd73fc63e9af2d9a7dcc5e8e9bab52ebc3b669b Mon Sep 17 00:00:00 2001 From: Hide_D Date: Wed, 29 Oct 2025 16:01:23 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20addTurn,=20subTurn,=20cutTurn=EC=97=90?= =?UTF-8?q?=EC=84=9C=20VarTurn60=20=EB=B2=84=EC=A0=84=20=ED=98=B8=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/func.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/hwe/func.php b/hwe/func.php index e7ea5903..0284e298 100644 --- a/hwe/func.php +++ b/hwe/func.php @@ -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'));