d8e58c9fafc7c7a7bf2bf8f802164b5a04a6a54a
1 <?php
declare(strict_types
=1);
3 require_once('common.php');
5 $taskMatrix = require 'taskMatrix.php';
8 (int)(new DateTimeImmutable('first monday of this month'))->format('d'),
9 (int)(new DateTimeImmutable('second monday of this month'))->format('d'),
10 (int)(new DateTimeImmutable('third monday of this month'))->format('d'),
11 (int)(new DateTimeImmutable('fourth monday of this month'))->format('d'),
14 $currentMonth = (int)(new DateTimeImmutable())->format('n');
15 $currentDayOfMonth = closest((new DateTimeImmutable())->format('d'), $mondays);
16 $currentSeason = getSeason($currentMonth);
17 $currentYear = (int)(new DateTimeImmutable())->format('Y');
18 $currentWeekOfMonth = closestIndex($currentDayOfMonth, $mondays);
20 $extractTasks = function($tasks, $path) {
21 return array_merge($tasks, file_exists($path) ?
lines(trim(file_get_contents($path))) : []);
24 $unfinishedForYear = array_diff(
26 function($season) use ($taskMatrix) {
27 return getTasksForTheSeason($season, $taskMatrix);
29 )(['summer', 'autumn', 'winter', 'spring'])),
30 array_reduce(getFilePathsForYear($currentYear), $extractTasks, [])
33 $unfinishedForSeason = array_diff(
34 getTasksForTheSeason($currentSeason, $taskMatrix),
35 array_reduce(getFilePathsForSeason($currentYear, $currentSeason), $extractTasks, [])
38 $unfinishedForMonth = array_diff(
39 getTasksForTheMonth($currentMonth, $taskMatrix),
40 array_reduce(getFilePathsForMonth($currentYear, $currentMonth), $extractTasks, [])
43 $filePathForWeek = getFilePathForWeek($currentYear, $currentMonth, $currentWeekOfMonth);
44 $unfinishedForWeek = array_diff(
45 getTasksForTheWeek($currentWeekOfMonth, $currentMonth, $taskMatrix),
46 file_exists($filePathForWeek) ?
lines(trim(file_get_contents($filePathForWeek))) : []
49 //EOY => (EOM & EOW) & !EOSx
50 //EOS => (EOM & EOW) & !EOY
51 $taskLists = array_merge(
52 isEndOfYear($currentYear, $currentMonth, $currentDayOfMonth) ?
[unlines(map(getStringAndCode
)($unfinishedForYear))] : [],
53 isEndOfSeason($currentYear, $currentMonth, $currentDayOfMonth) ?
[unlines(map(getStringAndCode
)($unfinishedForSeason))] : [],
54 isEndOfMonth($currentYear, $currentMonth, $currentDayOfMonth) ?
[unlines(map(getStringAndCode
)($unfinishedForMonth))] : [],
55 [unlines(map(getStringAndCode
)($unfinishedForWeek))]
58 $seasonName = ucfirst($currentSeason);
59 $goodOrBad = function($string, $goodOrBad) {
60 return getString($string . ($goodOrBad ?
'' : 'Good'));
64 [$goodOrBad('endOfWeek', $unfinishedForWeek)],
66 $goodOrBad('endOfMonth', $unfinishedForMonth),
67 $goodOrBad('andAlsoEndOfWeek', $unfinishedForWeek)
70 $goodOrBad('endOf' . $seasonName, $unfinishedForSeason),
71 $goodOrBad('andAlsoEndOfMonth', $unfinishedForMonth),
72 $goodOrBad('finallyEndOfWeek', $unfinishedForWeek)
75 $goodOrBad('endOfYear', $unfinishedForYear),
76 $goodOrBad('andAlsoEndOfMonth', $unfinishedForMonth),
77 $goodOrBad('finallyEndOfWeek', $unfinishedForWeek)
82 function($message, $list) {
85 is_array($message) ?
$message : [$message],
90 // Similar magic to tasks.php
92 isEndOfMonth($currentYear, $currentMonth, $currentDayOfMonth) +
93 isEndOfSeason($currentYear, $currentMonth, $currentDayOfMonth) +
94 (isEndOfYear($currentYear, $currentMonth, $currentDayOfMonth) ?
2 : 0) // EOY is independant of EOS, to get the right index need to add 2 instead of 1.
99 foreach ($messages as $message) {
100 sendToGroupChat($message);