Re: Days and hours
Re: Days and hours
- Subject: Re: Days and hours
- From: "Nigel Garvey" <email@hidden>
- Date: Thu, 20 Oct 2005 13:46:09 +0100
"Mark J. Reed" wrote on Wed, 19 Oct 2005 23:48:51 -0400:
>On 10/19/05, Nigel Garvey <email@hidden> wrote:
>>
>> >set myDate to current date
>> >set year of myDate to 1968
>> >set month of myDate to May
>> >set day of myDate to 5
>> >set time of myDate to (20 * 60 + 47) * 60
>>
>> There's a potential problem with this method, in that unless all the
>> elements of the current date are compatible with the date you want to
>> create, you'll get errors.
>
>
>Not errors, unless you mean "potentially erroneous results". AppleScript
>automatically adjusts to legal dates.
You're absolutely right! My apologies for that misstatement. Three
o'clock in the morning and all that....
kai wrote on Thu, 20 Oct 2005 02:55:10 +0100:
>Characteristically ingenious, Mr. G. :-)
Characteristically generous, Mr. E. :-)
>FWIW, I've just been tinkering with this
>slight variation:
>
>------------
>
>tell "1 1 1" to tell my date it
[etc.]
<Splutter!> Characteristically terse, Mr. E! Only three variables in
eighteen lines! It's interesting that that first line needs the 'my' to
avoid an error. Presumably it's because strings can't handle dates. You'd
no doubt enjoy this too:
script
end
tell "1 1 1" to tell result's date it
[etc.]
In terms of algorithm, your take on the idea involves a lot less work
than mine and seems to be about five times as fast. Of course, we've both
made the unconscious assumption that the name of every month in the local
language will consist of just one word....
I forgot to point out when I posted my script (though it should be fairly
obvious) that the way to get an AppleScript constant from the selected
month name would be:
set theChoice to (choose from list monthNames)
if theChoice is false then error number -128
set m to month of date (item 1 of theChoice)
And finally, for kai fans everywhere, here's a complete version with no
variables at all. :-)
tell "1 1 1" to tell (my date it) + 24 * days to tell {it + 7 * days,
date string's words & "1", 1} to considering case
set end to beginning's date string's words
repeat while end's item item 3 is in item 2
set item 3 to (item 3) + 1
end repeat
set end to {item 2's item item 3, end's item item 3}
repeat 10 times
set beginning's day to 32
set end's end to beginning's date string's word item 3
end repeat
its end
end considering
tell (choose from list result) to if it is false then
error number -128
else
my date (its beginning)'s month
end if
NG
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden