mnemosyne/lib/Mnemosyne/Schedule.pm

37 lines
1.5 KiB
Perl

package Mnemosyne::Schedule;
use strict;
use warnings;
# Resolves whether a task is due/upcoming/overdue/irrelevant for a given date.
# This module is the heart of the scheduling logic and must be well unit-tested.
#
# Public interface (all take a task hashref + a DateTime object for "today"):
#
# TODO: status($task, $today_dt) — returns one of: 'overdue', 'due', 'upcoming', 'inactive'
# Dispatches to the appropriate class handler below.
#
# TODO: next_due_date($task, $today_dt) — returns a DateTime of the next occurrence,
# or undef if the task has no upcoming date (e.g. inactive).
#
# --- Per-class handlers ---
#
# TODO: _monthly_date_due($task, $today_dt)
# Rule: fires on day_of_month each month.
# Short-month rule: if day_of_month > days-in-month, fire on last day of month.
#
# TODO: _monthly_weekday_due($task, $today_dt)
# Rule: fires on the Nth weekday (ordinal 1-4, or -1 for last) each month.
#
# TODO: _every_n_period_due($task, $today_dt)
# Rule: occurrences = anchor_date + k * (interval_n period_units), k=0,1,2,...
# Calendar-anchored; NOT reset by completion.
#
# TODO: _interval_due($task, $today_dt, $last_completion_dt)
# Rule: next_due = last_completion_dt + interval_days (or created_at if never done).
#
# TODO: _floating_show($task, $today_dt, $last_completion_dt)
# Rule: high → always; medium → every medium_float_days; low → weekly + randomised.
# Returns true/false (floating tasks are never "overdue", just shown or not).
1;