Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Re: Finding the dates for the reminder mail system by ikegami
in thread Finding the dates for the reminder mail system by d-evil

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-25 20:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found