Send Reminders Quarterly, Bi-Yearly, Yearly or… whatever!

New Feature

This morning I put the final touches on the latest feature for Sendrecurring: a longer than monthly option! Users can now schedule reminders to send any X number of months. However long you want!

You will see the new box when you go to create or edit any reminder:


This is a great feature that a lot of users have suggested. I really wish I could have implemented it sooner but it is a more difficult thing to code than you would initially think, due to every month having a different number of days and leap years, and that Python does not have an “Increment by Month” function in their datetime library.

For those that are curious I will brain dump a little on how I implemented it.

Technical Stuff Beyond This Point

The original system for monthly reminders was pretty simple and foolproof, I would simply add days to the current date until I was at the date that a reminder should be scheduled. This handled both cases of initial creation of a reminder and rescheduling a current reminder really well.

In the new system I could not do that. Reasons include that a new email will need to be sent this month, not X number of months away, and that a reminder past its send date due for rescheduling should be rescheduled X number of months away.

I added some checks.

1. I check if the current time is after the reminder/emails scheduled time (ie already past). If it is then I automatically start looking at future dates for it to be scheduled.

2. I check if the date of the reminder’s LAST scheduled send is before todays date. Brand new reminders will not have this, so that is an indicator that one is brand new. If today’s date is after the last scheduled send then that means it has been scheduled before and any subsequent schedulings will use the X number of months information.

A snippet of source code below (this is rough and untailored for the blog) but could make some sense if you really need to a solve  similar problem. Just ask me if you want clarification :D.

  if localdatetime > localsendtime:
      localsendtime += datetime.timedelta(days = 1)
    try: eml = email.localsendtime
    except: eml = None
    if eml and localdatetime > eml:
      #add months depending on monthpattern
      try: monthpattern = email.monthpattern
      except: monthpattern = 1
      #add months if the monthpattern is 2 or higher
      if monthpattern > 1:
        monthdays = (monthpattern)*30
        localsendtime += datetime.timedelta(days = monthdays)
    #add days until it is the correct date
    while getattr(localsendtime, "day") != email.rpattern:
      localsendtime += datetime.timedelta(days = 1)

A few of you may notice that I use monthpattern * 30 for the “month” increment. This is actually slightly lower than the real days per month average of 30.4. The downside to this is that if someone does a really long monthlypattern, the days could eventually be off. It would need to be off by an entire month for the subsequent datetime.timedelta(days = 1) to no longer “catch”  the desired date so there is some buffer for error.

I will be keeping a watchful eye on what happens with this. Anything over 75 months may be inaccurate, 6.25 years. I wonder if anyone would really want to be reminded about something that far off.

Leave a Reply

Your email address will not be published. Required fields are marked *