Re: Week of year - odd/even week
Re: Week of year - odd/even week
- Subject: Re: Week of year - odd/even week
- From: Emmanuel <email@hidden>
- Date: Fri, 1 Feb 2002 00:05:52 +0100
At 9:58 PM +0100 31/1/02, martin schiller wrote:
>
>
Can anyone help me with some pointers or a routine to determine the week
>
of the year? I'm trying to set a script to send me a reminder to put out
>
the yard waste container on alternate weeks.
Solutions have been provided which may or may not be correct.
The index of the week is:
------------------------------
1 + ((theDate - theFirst) div (7 * 86400))
------------------------------
theFirst being, not the first day of the year, but the first day of ... the
first week of the year!
Below I give the script to compute the first day of the first week of the
year which contains theDate.
------------------------------ tested (was included in Smile's distribution)
copy theDate to theFirst
set day of theFirst to 1
set month of theFirst to January
set time of theFirst to 0
repeat until (weekday of theFirst) is Thursday
set day of theFirst to 1 + (get day of theFirst)
end repeat
repeat until (weekday of theFirst) is Monday
set day of theFirst to 1 + (get day of theFirst)
end repeat
set theFirst to theFirst - 7 * 86400
------------------------------
HTH
Emmanuel