Re: Avoiding repetition
Re: Avoiding repetition
- Subject: Re: Avoiding repetition
- From: Paul Berkowitz <email@hidden>
- Date: Fri, 16 Jul 2004 07:25:24 -0700
On 7/16/04 7:01 AM, "Nigel Garvey" <email@hidden>
wrote:
>
Sorry. If I'd been awake, I'd have simplified that to:
>
>
set now to (current date)
>
set i to (now - (date "Monday, 6 January 1000 00:00:00")) mod weeks div
>
days + 1
>
set folderName to item i of {"A", "B", "C", "D", "E", "F", "G"}
>
myAction(folderName)
Certainly a lot clearer than the two 'now's. ;-)
>
>
... or of course:
>
>
set folderName to item (((current date) - (date "Monday, 6 January 1000
>
00:00:00")) mod weeks div days + 1) of {"A", "B", "C", "D", "E", "F", "G"}
>
myAction(folderName)
>
>
:-)
Useful for dealing with any date at all. If it's only ever going to be used
with current date or other recent dates, is there any reason to go all the
way back to 1000? Why not just use date "Monday, January 5, 2004 12:00:00
AM" or any other recent Monday, and save on the mod division? (You never
know, we might some day hit a number too big as a result of the initial
subtraction. ;-) Such things have been known to occur.) This does make it
valid for any date whatsoever, of course. So if Bernard comes across some
old files on his machine dating from 1472 it's reassuring to know that the
routine will still work.
--
Paul Berkowitz
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.