Re: Date of next Thursday
Re: Date of next Thursday
- Subject: Re: Date of next Thursday
- From: Allen Watson <email@hidden>
- Date: Wed, 15 Nov 2000 13:27:21 -0800
On or near 11/15/00 10:29 AM, Paul Berkowitz at email@hidden
observed:
>
set today to weekday of (get current date)
>
>
set theWeekdays to {Saturday, Friday, Thursday, Wednesday, Tuesday, Monday,
>
Sunday}
>
repeat with i from 1 to 7
>
if today is item i of theWeekdays then
>
set nextThursday to date string of ((current date) + ((i + 4) *
>
days))
>
exit repeat
>
end if
>
end repeat
>
nextThursday
With "day of week" from the "Date String Calculations" osax, this resolves
down to:
set curdate to (current date)
set today to day of week of curdate
set ThursOffset to ((7 - today) + 5) mod 7
set nextThursday to date string of ((curdate) + (ThursOffset * days))
Even without using an osax for getting the numeric day of week, you could
use a record and some clever code. I do this more as an exercise than as a
practical tool, since your script, Paul, is as efficient as anyone could
want.
set today to weekday of (get current date) as string
set today to (run script "set theWeekdays to {Sunday:1, Monday:2, Tuesday:3,
Wednesday:4, Thursday:5, Friday:6, Saturday:7}" & return & "set today to " &
today & " of theWeekdays")
set ThursOffset to ((7 - today) + 5) mod 7
set nextThursday to date string of ((current date) + (ThursOffset * days))
nextThursday
I used the "run script" because it was the only way I could think of to
translate the weekday name into a field name for the lookup in the record.
--
Peace be with you!
Allen <email@hidden> XNS Name: =Allen Watson
My web page: <
http://home.earthlink.net/~allenwatson/>