Hi,
I’m sure this is simple but I need some help anyway. I’m using Applescript’s “current date” comand but I only want a portion of the string. i.e Friday, March 30, 2007 15:54:07 but I only need March 30, 2007 section of text. I know I can’t count the characters as in my example for thetimeprocessed below because the length of charaters in the month changes so the only thing I can think of doing is searching between the first “,” and characters -10 any idea of how to do this or a better way of handling this?
Thanks for your time
set thedate to (current date) as string
set thetimeprocessed to characters -1 thru -8 of thedate as string
tell (current date) to set theDate to "" & month of it & " " & day of it & ", " & year of it
This would be better if you’re going to distribute this script to other people (it uses the International settings in System Preferences):
display dialog (date string of (current date))
-- or
display dialog (short date string of (current date))
Side note: characters as string is not the best method for you’re first example. First, it depends on AppleScript’s text item delimiters (because it creates a list and then coerces the list into text). Consider this:
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "~~BOO~~"
try
set thedate to (current date) as string
set thetimeprocessed to characters -1 thru -8 of thedate as string
end try
set AppleScript's text item delimiters to ASTID
display dialog thetimeprocessed
Also, it takes more resources than using text (text doesn’t involve a coercion like characters does):
set thedate to (current date) as string
set thetimeprocessed to text -1 thru -8 of thedate