(int)(new DateTimeImmutable('third monday of this month'))->format('d'),
(int)(new DateTimeImmutable('fourth monday of this month'))->format('d'),
];
- $closestMonday = closest($dt->format('d'), $mondays);
-
+ $currentMonth = (int)(new DateTimeImmutable())->format('m');
+ $currentDayOfMonth = closest((new DateTimeImmutable())->format('d'), $mondays);
+ $currentWeekOfMonth = array_search($currentDayOfMonth, $mondays);
+ $currentYear = (int)(new DateTimeImmutable())->format('Y');
$tasksForTheWeek = getTasksForTheWeek(
- array_search($closestMonday, $mondays),
+ $currentWeekOfMonth,
(int)$dt->format('m'),
require 'taskMatrix.php'
);
- $completedTasksFile = "$directory" . "/completed.txt";
+ $completedTasksFile = getFilePathForWeek($currentYear, $currentMonth, $currentWeekOfMonth);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
$this->replyWithMessage([