Re: Date of next Thursday
Re: Date of next Thursday
- Subject: Re: Date of next Thursday
- From: Nigel Garvey <email@hidden>
- Date: Thu, 16 Nov 2000 23:49:39 +0000
Allen Watson wrote on Wed, 15 Nov 2000 23:33:06 -0800:
>
On or near 11/15/00 3:17 PM, Nigel Garvey at email@hidden
>
observed:
>
>
> set dref to date "Thursday, 6 January 2000 00:00:00"
>
> set nextThursday to dref + (round (((current date) - dref) / weeks)
>
> rounding up) * weeks
>
>
Two lines! Makes us all look like idjits.
Not at all. I just happened to look at the problem in a way which
happened to produce a good - though not perfect - result. You were right
about the way it works. It treats the current date as part of a Thursday
- Wednesday week and rounds up to the beginning of the next such week. My
later variation eliminated the use of 'round' by adding a week and then
rounding *down* by means of 'div'. The version after that reduced the
number of math operations by subtract a 'mod' instead.
And it's down to one line now:
tell (current date) to set nextThursday to date string of ,
(it + weeks - (it - (date "Thursday, 6 January 2000 00:00:00")) mod
weeks)
("," is the line-continuation character.)
NG