[Remind-Fans] Periodic Reminders Using Omits

Daniel Graham daniel.graham at duke.edu
Sat Mar 25 12:13:28 EST 2006


I know this is cheating, but here is a simple python script that
will write the relevant remind entries to stdout which could, of
course, be redirected to a file "included" in your reminders file.

To use it you would need to create a datafile with the following
format:

---------- start datafile -----------------
startdate = (2006,1,2)
enddate = (2006,6,6)
holidays = [
   (2006,1,16), # Martin Luther King
   (2006,4,17), # Easter
   ]
---------- end datafile -------------------

Then invoke the following:

---------- start script -------------------
#!/usr/bin/python
#### edit the following to point to the datafile ####
datafile = "schedule.data"
#####################################################

import datetime
oneday = datetime.timedelta(days=1)

# Get the data
execfile(datafile)

# Convert relevant dates to datetime objects
startday = datetime.date(startdate[0],startdate[1],startdate[2])
endday = datetime.date(enddate[0],enddate[1],enddate[2])

skipdays = []
for date in holidays:
    skipdays.append(datetime.date(date[0],date[1],date[2]))

day = startday
count = 0
scheduledays = []
while day <= endday:
    if day.weekday() < 5:
        try:
            skipdays.index(day)
        except:
            sequenceday = (count % 6) + 1
            count += 1
            scheduledays.append("REM %s MSG Day %d" % \
                    (day.strftime('%a %d %b %Y'), sequenceday))
    day = day + oneday

numdays = len(scheduledays)
for i in range(numdays):
    # print "%s%%" % scheduledays[i]
    print "%s (%d/%d)%%" % (scheduledays[i],i+1,numdays)
---------- end script ---------------------

Sample output:

REM Mon 02 Jan 2006 MSG Day 1 (1/110)%
REM Tue 03 Jan 2006 MSG Day 2 (2/110)%
REM Wed 04 Jan 2006 MSG Day 3 (3/110)%
REM Thu 05 Jan 2006 MSG Day 4 (4/110)%
REM Fri 06 Jan 2006 MSG Day 5 (5/110)%
REM Mon 09 Jan 2006 MSG Day 6 (6/110)%
REM Tue 10 Jan 2006 MSG Day 1 (7/110)%
REM Wed 11 Jan 2006 MSG Day 2 (8/110)%
REM Thu 12 Jan 2006 MSG Day 3 (9/110)%
REM Fri 13 Jan 2006 MSG Day 4 (10/110)%
REM Tue 17 Jan 2006 MSG Day 5 (11/110)%
REM Wed 18 Jan 2006 MSG Day 6 (12/110)%
REM Thu 19 Jan 2006 MSG Day 1 (13/110)%
REM Fri 20 Jan 2006 MSG Day 2 (14/110)%
REM Mon 23 Jan 2006 MSG Day 3 (15/110)%
REM Tue 24 Jan 2006 MSG Day 4 (16/110)%
REM Wed 25 Jan 2006 MSG Day 5 (17/110)%
REM Thu 26 Jan 2006 MSG Day 6 (18/110)%
.
.
.
REM Thu 01 Jun 2006 MSG Day 5 (107/110)%
REM Fri 02 Jun 2006 MSG Day 6 (108/110)%
REM Mon 05 Jun 2006 MSG Day 1 (109/110)%
REM Tue 06 Jun 2006 MSG Day 2 (110/110)%

-Dan



More information about the Remind-fans mailing list