}
function closestIndex($n, array $list) {
- //return $list[closestIndex($n, $list)];
$a = map(function(int $v) use ($n) : int {
return (int)abs($v - $n);
})
(int)(new DateTimeImmutable('third monday of this month'))->format('d'),
(int)(new DateTimeImmutable('fourth monday of this month'))->format('d'),
];
- $currentWeekOfMonth = closestIndex($dt->format('d'), $mondays);
+ $currentWeekOfMonth = closestIndex($dt->format('d'), $mondays) + 1;
$completedTasksFile = getFilePathForWeek((int)$dt->format('Y'), (int)$dt->format('n'), $currentWeekOfMonth);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
$tasksForTheWeek = getTasksForTheWeek(
(int)(new DateTimeImmutable('fourth monday of this month'))->format('d'),
];
$currentMonth = (int)(new DateTimeImmutable())->format('m');
- $currentWeekOfMonth = closestIndex((new DateTimeImmutable())->format('d'), $mondays);
+ $currentWeekOfMonth = closestIndex((new DateTimeImmutable())->format('d'), $mondays) + 1;
$currentYear = (int)(new DateTimeImmutable())->format('Y');
$tasksForTheWeek = getTasksForTheWeek(
$currentWeekOfMonth,
(int)(new DateTimeImmutable('third monday of this month'))->format('d'),
(int)(new DateTimeImmutable('fourth monday of this month'))->format('d'),
];
- $currentWeekOfMonth = closestIndex($dt->format('d'), $mondays);
+ $currentWeekOfMonth = closestIndex($dt->format('d'), $mondays) + 1;
$completedTasksFile = getFilePathForWeek((int)$dt->format('Y'), (int)$dt->format('n'), $currentWeekOfMonth);
];
$currentMonth = (int)(new DateTimeImmutable())->format('m');
$currentDayOfMonth = closest((new DateTimeImmutable())->format('d'), $mondays);
-$currentWeekOfMonth = closestIndex($currentDayOfMonth, $mondays);
+$currentWeekOfMonth = closestIndex($currentDayOfMonth, $mondays) + 1;
$taskLists = array_merge(
isStartOfSeason($currentMonth, $currentDayOfMonth) ? [unlines(map(getStringAndCode)(getTasksForTheSeason(getSeason($currentMonth), $taskMatrix)))] : [],
$currentDayOfMonth = closest((new DateTimeImmutable())->format('d'), $mondays);
$currentSeason = getSeason($currentMonth);
$currentYear = (int)(new DateTimeImmutable())->format('Y');
-$currentWeekOfMonth = closestIndex($currentDayOfMonth, $mondays);
+$currentWeekOfMonth = closestIndex($currentDayOfMonth, $mondays) + 1;
$extractTasks = function($tasks, $path) {
return array_merge($tasks, file_exists($path) ? lines(trim(file_get_contents($path))) : []);