$message = getTelegram()->getWebHookUpdates()->get('message') ? getTelegram()->getWebHookUpdates()->get('message')->get('text') : '';
if ($between = between(reveal($message ?? ''), '[taskid]')) {
- // The actual date/time when the script is called
- $currentYear = (int)(new DateTimeImmutable())->format('Y');
- $currentMonth = (int)(new DateTimeImmutable())->format('n');
- $currentDay = (int)(new DateTimeImmutable())->format('d');
-
- // The years/months/weeks that we are "rewinding" to, for calculations
- $yearForThisWeek = getYearWeekBeginsIn($currentYear, $currentMonth, $currentDay);
- $monthForThisWeek = getMonthWeekBeginsIn($currentYear, $currentMonth, $currentDay);
- $seasonForThisWeek = getSeason($monthForThisWeek);
- $weekNum = getWeekNumber($currentYear, $currentMonth, $currentDay);
-
- $completedTasksFile = getFilePathForWeek($yearForThisWeek, $monthForThisWeek, $weekNum);
+ $monday = turnBackTime(new DateTimeImmutable());
+ $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
$tasksForTheWeek = getTasksForTheWeek(
- $yearForThisWeek,
- $monthForThisWeek,
- $weekNum,
+ $monday->year,
+ $monday->month,
+ $monday->weekNum,
require 'taskMatrix.php'
);
protected $description = 'List tasks for this week';
public function handle($arguments) {
- // The actual date/time when the script is called
- $currentYear = (int)(new DateTimeImmutable())->format('Y');
- $currentMonth = (int)(new DateTimeImmutable())->format('n');
- $currentDay = (int)(new DateTimeImmutable())->format('d');
-
- // The years/months/weeks that we are "rewinding" to, for calculations
- $yearForThisWeek = getYearWeekBeginsIn($currentYear, $currentMonth, $currentDay);
- $monthForThisWeek = getMonthWeekBeginsIn($currentYear, $currentMonth, $currentDay);
- $seasonForThisWeek = getSeason($monthForThisWeek);
- $weekNum = getWeekNumber($currentYear, $currentMonth, $currentDay);
-
+ $monday = turnBackTime(new DateTimeImmutable());
$tasksForTheWeek = getTasksForTheWeek(
- $yearForThisWeek,
- $monthForThisWeek,
- $weekNum,
+ $monday->year,
+ $monday->month,
+ $monday->weekNum,
require 'taskMatrix.php'
);
- $completedTasksFile = getFilePathForWeek($yearForThisWeek, $monthForThisWeek, $weekNum);
+ $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
if (!array_diff($tasksForTheWeek, $completedTasks)) {
protected $description = 'Mark a task as completed';
public function handle($arguments) {
- // The actual date/time when the script is called
- $currentYear = (int)(new DateTimeImmutable())->format('Y');
- $currentMonth = (int)(new DateTimeImmutable())->format('n');
- $currentDay = (int)(new DateTimeImmutable())->format('d');
-
- // The years/months/weeks that we are "rewinding" to, for calculations
- $yearForThisWeek = getYearWeekBeginsIn($currentYear, $currentMonth, $currentDay);
- $monthForThisWeek = getMonthWeekBeginsIn($currentYear, $currentMonth, $currentDay);
- $seasonForThisWeek = getSeason($monthForThisWeek);
- $weekNum = getWeekNumber($currentYear, $currentMonth, $currentDay);
-
+ $monday = turnBackTime(new DateTimeImmutable);
$tasksForTheWeek = getTasksForTheWeek(
- $yearForThisWeek,
- $monthForThisWeek,
- $weekNum,
+ $monday->year,
+ $monday->month,
+ $monday->weekNum,
require 'taskMatrix.php'
);
- $completedTasksFile = getFilePathForWeek($yearForThisWeek, $monthForThisWeek, $weekNum);
+ $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
if (!array_diff($tasksForTheWeek, $completedTasks)) {