Re: Repaying help by posting small Applescripts
Re: Repaying help by posting small Applescripts
- Subject: Re: Repaying help by posting small Applescripts
- From: Graff <email@hidden>
- Date: Fri, 30 Apr 2004 08:45:53 -0400
On Apr 30, 2004, at 8:14 AM, Christopher Stone wrote:
At 04:58 -0400 04/30/2004, Graff wrought:
Your convertMonthToInteger function works fine but here's an
alternative that does the same job and does it with less clutter in
your script:
Jaguar can now do the direct coercion:
on dateToInt(theDate)
tell theDate
set m to it's month as integer
if m < 10 then set m to "0" & m
end tell
end dateToInt
set d to date "Thursday, May 04, 1961 11:40:00"
dateToInt(d)
--> 05
That's basically what I said in the second part of my comment...
:-)
Here it is again:
^^^^^^^^^^^^
if you are using AppleScript 1.9 or later you can just do:
-------------
on convertMonthToInteger(theMonth)
if ((theMonth as integer) < 10) then
return "0" & (theMonth as integer)
else
return "" & (theMonth as integer)
end if
end convertMonthToInteger
-------------
This is because AppleScript 1.9 allows coercion from the month
constants to integers.
^^^^^^^^^^^^
- Ken
_______________________________________________
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.