feat: addTurn, subTurn, cutTurn에서 VarTurn60 버전 호환
This commit is contained in:
@@ -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'));
|
||||
|
||||
Reference in New Issue
Block a user