feat: due resolution and cascade math
Also: StoresUtc trait normalizes datetime casts to UTC (controller ruling). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BCrwHHnGCB5XH968Nxokqw
This commit is contained in:
27
core/app/Scheduling/Cascade.php
Normal file
27
core/app/Scheduling/Cascade.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Scheduling;
|
||||
|
||||
use Carbon\CarbonImmutable;
|
||||
|
||||
final class Cascade
|
||||
{
|
||||
/**
|
||||
* Точки каскада между стартом и днём срока: старт, затем каждый раз, когда
|
||||
* до срока остаётся вдвое меньше дней, до одного дня. Обе даты — локальные
|
||||
* полуночи в одном поясе. Возвращает локальные полуночи по возрастанию.
|
||||
*
|
||||
* @return list<CarbonImmutable>
|
||||
*/
|
||||
public static function points(CarbonImmutable $fireStart, CarbonImmutable $dueDay): array
|
||||
{
|
||||
$d = (int) round($fireStart->diffInDays($dueDay));
|
||||
$points = [];
|
||||
while ($d >= 1) {
|
||||
$points[] = $dueDay->subDays($d);
|
||||
$d = intdiv($d, 2);
|
||||
}
|
||||
|
||||
return $points;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user