From f8276a0732f90fdeceb94ba82f4d8d8934276229 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Wed, 19 Dec 2018 13:47:12 +0800 Subject: [PATCH] Make the task list command use the getFilePath function --- purjolok.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/purjolok.php b/purjolok.php index 5cab7de..48f360b 100644 --- a/purjolok.php +++ b/purjolok.php @@ -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([ -- 2.11.0