property unixEpoch : (date "Thursday, January 1, 1970 12:00:00 AM") + (time to GMT)
to internalISO8601(theDate)
((theDate - (time to GMT)) as «class isot» as string) & "Z"
end internalISO8601
to externalISO8601(theDate)
tell application "System Events"
local thePlist, theXML
make new property list item with properties {value:theDate}
set thePlist to text of result
make new XML data with properties {text:thePlist}
set theXML to result
get the first XML element of the first XML element of theXML
get value of result
end tell
end externalISO8601
set summerDate to date "Saturday, June 30, 2007 5:05:00 PM"
set winterDate to date "Saturday, February 20, 2010 1:00:00 AM"
log internalISO8601(unixEpoch) -- > (*1970-01-01T00:00:00Z*)
log externalISO8601(unixEpoch) --> (*1970-01-01T00:00:00Z*)
log internalISO8601(winterDate) --> (*2010-02-20T09:00:00Z*)
log externalISO8601(winterDate) --> (*2010-02-20T09:00:00Z*)
log internalISO8601(summerDate) --> (*2007-07-01T01:05:00Z*) *** wrong!
log externalISO8601(summerDate) --> (*2007-07-01T00:05:00Z*) *** right!!
log summerDate - unixEpoch --> (*1.1832519E+9*) *** wrong...ish
So Mark *is* right when he says that AppleScript converts dates to a POSIX timestamp using just the current value of Standard Addition's (time to GMT).
*BUT* it also seems to correct this issue when sending the date to an external app like System Events or iPhoto. I wonder if this is consistent across previous versions of OS X.