MACSCRPT Archives

May 2003

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Nigel Garvey <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Sat, 24 May 2003 10:33:20 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (45 lines)
Emmanuel wrote on Fri, 23 May 2003 10:07:24 +0200:

>Namely, I suggest that we use "days" instead of the constants, e.g. "28 *
>days". I hope this might help scripters use it without having to maintain
>some URL or some "monthindex()" handler.
>
>-------------------------- tested for WWII D-Day and my birthday
>on MonthIndexFromDate(theDate)
>        copy theDate to theOtherDate
>        set month of theOtherDate to january
>        1 + (theDate - theOtherDate) div (28 * days)
>end MonthIndexFromDate
>-----------------------------------

That *is* a "monthindex()" handler! ;-)

But if you're going to introduce extra maths for the sake of scripters,
you may as well go the whole hog for the sake of the process itself and
make it proof against the "earlier than 1904" bug (which is a Mac OS
problem rather than a French Vanilla one). You can use either a prefixed
French (or American) Vanilla:

  if theDate's year comes before 1904 then
    copy theDate to theDate
    set theDate's year to (theDate's year) + 3 * 400
  end if
  copy theDate to theOtherDate
  set theOtherDate's month to January
  1 + (theDate - theOtherDate) div (28 * days)

... or the just-invented "English Fudge":

  copy theDate to b
  set b's month to January
  1 - (b - 1 - theDate) div (28 * days)


[Quoted out of sequence]
>(I've tagged "OT" because
>this remark is not operationally relevant, just fun.)

Speaking of "[OT]", what about that thread "Anyone Familiar With This?"?

NG

ATOM RSS1 RSS2