[Remind-Fans] Week Numbers. (solved)
Geoff
ghubbard at instihost.com
Sat Mar 20 14:32:57 EDT 2010
Thanks to David's clues I managed to come up with what I think are some
working week number functions. (see below)
Some more questions I came up with along the way:
Is there a real 'never'? (I used today()+1)
My week numbers work with remind -(c|p|s) but seem to not work correctly
with -n. Why is this? Is it a bug? Does it matter?
Geoff.
----------
# WeekNumbers.rem
#
# By: Geoff Hubbard [firstinitial][lastname]@['instihost'].['com']
# Version: 1.0 20/03/2010
#
# What I actually WANTED to be able to do:
#REM Week08 OMIT Sat Sun MSG This is week 8
# Is there a real 'never'?
SET never today()+1
# Find the start of the current week.
REM Mon SCANFROM [today()-6] SATISFY 1
IF trigvalid()
SET week[weekno(trigdate())]_start trigdate()
ENDIF
FSET startWeek(x) value("week"+x+"_start", never )
FSET isWeek(week_number) (weekno(today()) == week_number)
FSET allWeek(week_number) iif( isWeek(week_number),today(),never)
FSET weekdaysWeek(week_number) iif(isWeek(week_number) && wkdaynum(today())%6>0 ,today(),never)
FSET weekendWeek(week_number) iif(isWeek(week_number) && wkdaynum(today())%6==0 ,today(),never)
# Set this shortcut to be whichever of the above makes the most sense for you.
FSET week(x) allWeek(x)
#####################################
#Examples:
# How to run:
#$ remind -ishowExamples=1 -m -c WeekNumbers.rem March 2010
IF defined("showExamples")
#####################################
# All 7 days of a week.
#####################################
# This is close to what I wanted
REM [allWeek(9)] MSG All of week 9 (1)
# Based on the date of the start of the week.
REM [startWeek(9)] *1 UNTIL [startWeek(9)+6] MSG All of week 9 (2)
# (Note: You don't actually need the until.)
REM [startWeek(9)] *1 MSG All of week 9 (3)
# You could also do it using Satisfy
REM SATISFY [isWeek(9)] MSG All of week 9 (4)
#####################################
# A) Just the weekdays
#####################################
# How to just do weekdays (as I originaly envisioned)
REM [allWeek(10)] OMIT Sat Sun SKIP MSG Week 10 weekday. (a1)
# Some other ways:
REM [startWeek(10)] *1 UNTIL [startWeek(10)+4] MSG Week 10 weekday. (a2)
REM [weekdaysWeek(10)] MSG Week 10 weekday. (a3)
REM Mon Tue Wed Thu Fri SATISFY [isWeek(10)] MSG Week 10 weekday. (a4)
# (This is probably a horrible abuse of the Zen of Remind)
REM Mon Tue Wed Thur Fri [allWeek(10)] MSG Week 10 weekday. (a5)
#####################################
# B) Just the weekend
#####################################
REM Sat Sun [allWeek(11)] MSG Week 11 weekend. (b1)
REM [weekendWeek(11)] MSG Week 11 weekend. (b2)
REM Sat Sun SATISFY [isWeek(11)] MSG Week 11 weekend. (b3)
REM [allWeek(11)] OMIT Mon Tue Wed Thur Fri SKIP MSG Week 11 weekend. (b4)
REM [startWeek(11)+5] *1 MSG Week 11 weekend. (b5)
#####################################
# C) Specific days
#####################################
# Just Monday/Wednesday/Friday
REM Mon Wed Fri [allWeek(12)] MSG odd weekdays of week 12 (c1)
REM Mon Wed Fri SATISFY [isWeek(12)] MSG odd weekdays of week 12 (c2)
REM [startWeek(12)] *1 OMIT Tue Thur Sat Sun SKIP MSG odd weekdays of week 12 (c3)
#####################################
# D) Single day
#####################################
# only Tuesday
REM Tue [allWeek(13)] MSG Tuesday of week 13. (d1)
REM Tue [startWeek(13)] MSG Tuesday of week 13. (d2)
REM Tue [weekdaysWeek(13)] MSG Tuesday of week 13. (d3)
REM Tue SATISFY [isWeek(13)] MSG Tuesday of week 13. (d4)
ENDIF
# End Examples
#####################################
More information about the Remind-fans
mailing list