Make the task list command use the getFilePath function
authorCameron Ball <cameron@cameron1729.xyz>
Wed, 19 Dec 2018 05:47:12 +0000 (13:47 +0800)
committerCameron Ball <cameron@cameron1729.xyz>
Fri, 28 Dec 2018 06:27:20 +0000 (14:27 +0800)
purjolok.php

index 5cab7de..48f360b 100644 (file)
@@ -138,15 +138,17 @@ getTelegram()->addCommand(
                 (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([