[Remind-Fans] week numbers

Terry Brown terry_n_brown at yahoo.com
Tue Sep 16 19:16:55 EDT 2008


On Tue, 16 Sep 2008 23:29:05 +0200
Guido Arnold <guido at fsfe.org> wrote:

> Hello,
> 
> I've been looking for an option to show the week numbers in the
> postscript output.

Hmm, I think I just spent 30 minutes answering the wrong question :-)

I was thinking, how do you calculate the week number.  It turned out to
be harder than I though, I ended up with this:

# day of week (Monday = 0) for Jan. 1 for 'this' year
SET jan1dow (wkdaynum(date(year(today()), 1, 1))+6)%7

# days in week 1, the partial week
SET week1 = 7 - jan1dow

# Day of year, Jan 1 = 1
SET doy today() - date(year(today()), 1, 1) + 1

SET wholeWeeks = (doy-week1)/7
SET daysLeft = iif(doy > week1, doy-week1-7*wholeWeeks, 0)

msg Week = [wholeWeeks + sgn(daysLeft) + sgn(week1)]

I think that works although I haven't tested it completely.  This is
using the ISO Monday is the first day of the week rule.  There are 53
weeks in leap years starting on Thursdays, like 2004.
http://en.wikipedia.org/wiki/Leap_year_starting_on_Thursday

But... how to get that into the PS output?

mon msg Week = [wholeWeeks + sgn(daysLeft) + sgn(week1)]

adds week = N to all the Mondays on the calendar, but that's not so
great when the first week doesn't have a Monday in it.

Anyway, that's what I came up with.

Cheers -Terry

> I couldn't find anything in the man pages of remind and rem2ps or the
> wiki.
> 
> I also checked the archive and found a posting with the same question
> in 2005, but there weren't any responses. And since 2006 wyrd is able
> to show week numbers, but that isn't what I am looking for.
> 
> I am afraid, that it is just too obvious that I don't see it. 
> 
> So, could somebody point me to the right direction? 
> 
> Thanks,
> 
> Guido




More information about the Remind-fans mailing list