• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Date of next Thursday
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: Date of next Thursday
      • From: Dave Balderstone <email@hidden>
  • Prev by Date: Offset in paragraphs
  • Next by Date: Re: Count selected pixcel with Photoscripter
  • Previous by thread: Re: Date of next Thursday
  • Next by thread: Re: Date of next Thursday
  • Index(es):
    • Date
    • Thread