tell application "Microsoft Excel" to ¬
set XlDt to the value of ¬
cell 197 of column 4
-- displays as "3/8/2009 2:00:00 AM" in Excel
-- (3/8/09 was a Spring Forward day.)
log "XlDt=" & XlDt --> 1:00:00 AM
set SIXlDt to strftime XlDt into "%FT%TZ" with GMT
log "SIXlDt=" & SIXlDt --> 2009-03-08T09:00:00Z
set ASDtStr to "3/8/09 1:00 AM"
set ASdt to date ASDtStr
log "ASdt=" & ASdt --> 1:00:00 AM
set SIASdt to strftime ASdt into "%FT%TZ" with GMT
log "SIASdt =" & SIASdt --> 2009-03-08T09:00:00Z --The same!
log "XlDT - ASDt=" & (XlDt - ASdt) --> 3600
-- Try 2AM instead...
set ASDtStr to "3/8/09 2:00 AM"
set ASdt to date ASDtStr
log "ASdt=" & ASdt --> 3:00:00 AM --Hogwash!
set SIASdt to strftime ASdt into "%FT%TZ" with GMT
log "SIASdt =" & SIASdt --> 2009-03-08T10:00:00Z
log "XlDT - ASDt=" & (XlDt - ASdt) --> -3600
(*XlDt=Sunday, March 8, 2009 1:00:00 AM*)
(*SIXlDt=2009-03-08T09:00:00Z*)
(*ASdt=Sunday, March 8, 2009 1:00:00 AM*)
(*SIASdt =2009-03-08T09:00:00Z*)
(*XlDT - ASDt=3600*)
(*ASdt=Sunday, March 8, 2009 3:00:00 AM*)
(*SIASdt =2009-03-08T10:00:00Z*)
(*XlDT - ASDt=-3600*)
Fortunately, strftime expresses GMT for the same times with identical strings. Thus, no matter how the apps choose to express the local time, the GMT-string version of the two times will compare as equal.
Thank you, Unix, for working this out, and thank you, Satimage, for making it available, and thank you, Emmanuel, for pointing it out.
--Gil
Using OS 10.6.4 and AS 2.1.2