Does anyone know how I could change this string “2007-08-08” into an actual date.
Ex Change “2007-08-08” to Wednesday, August 8th, 2007. I need to be able to do it for any date. What I am trying to accomlish is to get applescript to automatically figure out that August 8th, 2007 was a Wednesday.
I am having a problem now, I dont know what the deal is.
Using the “as «class isot» as date” works great except for when I use the following code. I can’t figure out what’s wrong with these statements. I am parsing an XML to extract the date which returns the following “2007-08-08T00:00:00” but when it gets to the last statement I get an error message that says “Can’t make “2007-08-08T00:00:00” into type «class isot»”
tell application "System Events"
set xml_file to choose file
set xml_file_string to xml_file as string
set F to XML file xml_file_string
-- <dataroot>
set root to XML element 1 of F
set air_date to XML element 1 of root
set air_date_extract to value of XML element 10 of air_date
end tell
set converted_air_date to air_date_extract as «class isot» as date
Unicode text won’t coerce properly (which is likely what you’re getting from the XML file). Try something like this:
set air_date_extract to "2007-04-10T18:56:00" as Unicode text -- example
set {text:converted_air_date} to (air_date_extract as string)
set converted_air_date to converted_air_date as «class isot» as date