1 <?php
declare(strict_types
=1);
3 require_once('common.php');
5 $taskMatrix = require 'taskMatrix.php';
7 // The actual date/time when the script is called
8 $currentYear = (int)(new DateTimeImmutable())->format('Y');
9 $currentMonth = (int)(new DateTimeImmutable())->format('n');
10 $currentDay = (int)(new DateTimeImmutable())->format('d');
12 // The years/months/weeks that we are "rewinding" to, for calculations
13 $yearForThisWeek = getYearWeekBeginsIn($currentYear, $currentMonth, $currentDay);
14 $monthForThisWeek = getMonthWeekBeginsIn($currentYear, $currentMonth, $currentDay);
15 $seasonForThisWeek = getSeason($monthForThisWeek);
16 $weekNum = getWeekNumber($currentYear, $currentMonth, $currentDay);
17 $dayNum = getDayNumber($currentYear, $currentMonth, $currentDay);
19 $taskLists = array_merge(
20 isStartOfSeason($monthForThisWeek, $dayNum) ?
[unlines(map(getString
)(getTasksForTheSeason($seasonForThisWeek, $taskMatrix)))] : [],
21 isStartOfMonth($dayNum) ?
[unlines(map(getString
)(getTasksForTheMonth($monthForThisWeek, $taskMatrix)))] : [],
22 [unlines(map(getString
)(getTasksForTheWeek($yearForThisWeek, $monthForThisWeek, $weekNum, $taskMatrix)))]
26 [getString('happyMonday')],
28 [getString('beginningOf'. ucfirst(getMonthName($monthForThisWeek))), getString('thisMonthThereAre', count(getTasksForTheMonth($monthForThisWeek, $taskMatrix)))],
29 getString('anywayHeresTheWeek')
32 getString('beginningOf' . ucfirst(getSeason($monthForThisWeek))),
33 [getString('anywayHeresTheMonth'), getString('thisMonthThereAre', count(getTasksForTheMonth($monthForThisWeek, $taskMatrix)))],
34 getString('finallyHeresTheWeek')
39 function($message, $list) {
42 is_array($message) ?
$message : [$message],
47 // Magic. startOfSeason implies startofMonth so we get 2, start of month without start of season gives 1 and
48 // a regular week (not the start of a season or month) gives 0. And this is how the indicies are ordered in the array.
49 $taskMessages[(int)isStartOfSeason($monthForThisWeek, $dayNum) +
(int)isStartOfMonth($dayNum)],
53 foreach ($messages as $message) {
54 sendToGroupChat($message);