Implement closest and closestIndex in a type-safer(ish...) way
[SonOfLokstallBot.git] / src / unfinished.php
index 55cb519..d8e58c9 100644 (file)
@@ -15,7 +15,7 @@ $currentMonth = (int)(new DateTimeImmutable())->format('n');
 $currentDayOfMonth = closest((new DateTimeImmutable())->format('d'), $mondays);
 $currentSeason = getSeason($currentMonth);
 $currentYear = (int)(new DateTimeImmutable())->format('Y');
-$currentWeekOfMonth = array_search($currentDayOfMonth, $mondays);
+$currentWeekOfMonth = closestIndex($currentDayOfMonth, $mondays);
 
 $extractTasks = function($tasks, $path) {
     return array_merge($tasks, file_exists($path) ? lines(trim(file_get_contents($path))) : []);
@@ -46,7 +46,7 @@ $unfinishedForWeek = array_diff(
     file_exists($filePathForWeek) ? lines(trim(file_get_contents($filePathForWeek))) : []
 );
 
-//EOY => (EOM & EOW) & !EOS
+//EOY => (EOM & EOW) & !EOSx
 //EOS => (EOM & EOW) & !EOY
 $taskLists = array_merge(
     isEndOfYear($currentYear, $currentMonth, $currentDayOfMonth) ? [unlines(map(getStringAndCode)($unfinishedForYear))] : [],