• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Repaying help by posting small Applescripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


References: 
 >Repaying help by posting small Applescripts (From: Richard Covert <email@hidden>)
 >Re: Repaying help by posting small Applescripts (From: Graff <email@hidden>)
 >Re: Repaying help by posting small Applescripts (From: Christopher Stone <email@hidden>)

  • Prev by Date: Re: Repaying help by posting small Applescripts
  • Next by Date: Selecting a different volume
  • Previous by thread: Re: Repaying help by posting small Applescripts
  • Next by thread: Re: Repaying help by posting small Applescripts
  • Index(es):
    • Date
    • Thread