}
const getFilePathForWeek = 'getFilePathForWeek';
-function getFilePathForWeek(int $year, int $monthNum, int $weekNum) {
+function getFilePathForWeek(int $year, int $monthNum, int $weekNum, string $base) {
// December is part of next year's summer
$seasonYear = $year;
return sprintf(
- 'tasks/%s/%s/%s/week%s.txt',
+ '%s/tasks/%s/%s/%s/week%s.txt',
+ $base,
$seasonYear,
getSeason($monthNum),
getMonthName($monthNum),
return $year - (int)($month == 1 && getMonthWeekBeginsIn($year, $month, $day) == 12);
}
-function getFilePathsForMonth(int $year, int $monthNum) {
- return map(function($week) use ($year, $monthNum){
- return getFilePathForWeek($year, $monthNum, $week);
+function getFilePathsForMonth(int $year, int $monthNum, string $base) {
+ return map(function($week) use ($year, $monthNum, $base){
+ return getFilePathForWeek($year, $monthNum, $week, $base);
})(range(1, count(getMondaysForMonth($year, $monthNum))));
}
-function getFilePathsForSeason(int $year, string $season) {
- return array_merge(...map(function($monthNum) use ($year) {
+function getFilePathsForSeason(int $year, string $season, string $base) {
+ return array_merge(...map(function($monthNum) use ($year, $base) {
// Summer of the current year includes december of the previous year.
$seasonYear = $year - ($monthNum == 12 ? 1 : 0);
- return getFilePathsForMonth($seasonYear, $monthNum);
+ return getFilePathsForMonth($seasonYear, $monthNum, $base);
})(array_filter(range(1,12), function($month) use ($season) {
return getSeason($month) == $season;
})));
}
-function getFilePathsForYear(int $year) {
- return array_merge(...map(function($season) use ($year) {
- return getFilePathsForSeason($year, $season);
+function getFilePathsForYear(int $year, string $base) {
+ return array_merge(...map(function($season) use ($year, $base) {
+ return getFilePathsForSeason($year, $season, $base);
})(['summer', 'winter', 'spring', 'autumn']));
}
if ($between = between(reveal($message ?? ''), '[taskid]')) {
$monday = turnBackTime(new DateTimeImmutable);
- $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum);
+ $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum, PATH_TO_TASKS_FILES);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
$tasksForTheWeek = getTasksForTheWeek(
$monday->year,
require 'taskMatrix.php'
);
- $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum);
+ $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum, PATH_TO_TASKS_FILES);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
if (!array_diff($tasksForTheWeek, $completedTasks)) {
require 'taskMatrix.php'
);
- $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum);
+ $completedTasksFile = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum, PATH_TO_TASKS_FILES);
$completedTasks = file_exists($completedTasksFile) ? lines(trim(file_get_contents($completedTasksFile))) : [];
if (!array_diff($tasksForTheWeek, $completedTasks)) {
return getTasksForTheSeason($season, $taskMatrix);
}
)(['summer', 'autumn', 'winter', 'spring'])),
- array_reduce(getFilePathsForYear($monday->year), $extractTasks, [])
+ array_reduce(getFilePathsForYear($monday->year, PATH_TO_TASKS_FILES), $extractTasks, [])
);
$unfinishedForSeason = array_diff(
getTasksForTheSeason($monday->season, $taskMatrix),
- array_reduce(getFilePathsForSeason($monday->year, $monday->season), $extractTasks, [])
+ array_reduce(getFilePathsForSeason($monday->year, $monday->season, PATH_TO_TASKS_FILES), $extractTasks, [])
);
$unfinishedForMonth = array_diff(
getTasksForTheMonth($monday->month, $taskMatrix),
- array_reduce(getFilePathsForMonth($monday->year, $monday->month), $extractTasks, [])
+ array_reduce(getFilePathsForMonth($monday->year, $monday->month, PATH_TO_TASKS_FILES), $extractTasks, [])
);
-$filePathForWeek = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum);
+$filePathForWeek = getFilePathForWeek($monday->year, $monday->month, $monday->weekNum, PATH_TO_TASKS_FILES);
$unfinishedForWeek = array_diff(
getTasksForTheWeek($monday->year, $monday->month, $monday->weekNum, $taskMatrix),
file_exists($filePathForWeek) ? lines(trim(file_get_contents($filePathForWeek))) : []