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:
Thu, 22 May 2003 11:07:50 +0100
Content-Type:
text/plain
Parts/Attachments:
text/plain (31 lines)
Nigel Garvey wrote on Thu, 22 May 2003 01:52:39 +0100:

>  on dateTommyydd(theDate)
>    set {day:dd, year:yyyy} to theDate
>    copy theDate to b
>    set b's month to January
>    set mm to (theDate - b + 3944592) div 2629728
>    return text 2 thru -1 of ((100000000 + mm * 1000000 + dd * 10000 +
>yyyy) as string)
>  end dateTommyydd

Sorry about the handler name. Late-night brain seizure.

The addition of 100000000 in the return line is to generate a leading
zero when mm is less than 10. This step can be optimised out by changing
one of the numbers in the previous line.

  on dateTommddyyyy(theDate)
    set {day:dd, year:yyyy} to theDate
    copy theDate to b
    set b's month to January
    set mmPlus100 to (theDate - b + 266917392) div 2629728
    return text 2 thru 9 of ((mmPlus100 * 1000000 + dd * 10000 + yyyy) as
string)
  end dateTommddyyyy

This can be done using no variables other than the parameter, but the
above's more efficient. :-)

NG

ATOM RSS1 RSS2