in reply to Finding the dates for the reminder mail system
Isn't this as simple as running the script every Wed and Fri (say as a cron job), and sending an email for every due date that's [0..14] (or [1..14]*) days away from today?
For the last reminder,
On Wednesdays, check if the due date is [1..2] (or [0..1]**) days away from today.
On Fridays, check if the due date is [1..5] (or [0..4]**) days away from today.
* — If you don't want notifications on the due date.
** — If you want the special notification be to sent before the due date.
Update: Untested code:
use Date::Calc qw( Day_of_Week Delta_Days Today ); use List::Util qw( min ); my ($ty,$tm,$td) = Today(); for (...{ tasks }...) { my ($dy,$dm,$dd) = ...{ due date of task }...; my $delta = Delta_Days($ty,$tm,$td, $dy,$dm,$dd); next if $delta < 0; # Don't care about past-due tasks. next if $delta > 14; # Don't care about due dates that far ahead. my $ddow = Day_of_Week($dy,$dm,$dd); # $cc_super is true if this is the last # Wednesday or Friday before the due date. my $days_to_wed = (3 - $ddow) % 7; my $days_to_fri = (5 - $ddow) % 7; my $days_to_next = min $days_to_wed, $days_to_fri; my $cc_super = ( $delta > 0 && $delta <= $days_to_next ); send_reminder($cc_super, ...); }
Update: Fixed typo in code resulting in the error mentioned in reply.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Finding the dates for the reminder mail system
by d-evil (Novice) on Nov 09, 2008 at 14:57 UTC | |
by ikegami (Patriarch) on Nov 09, 2008 at 15:27 UTC |