• 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
Daylight Savings Time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Daylight Savings Time


  • Subject: Daylight Savings Time
  • From: Gil Dawson <email@hidden>
  • Date: Fri, 20 Aug 2010 18:51:26 -0700

Thank you, Emmanuel, for saving my bacon AGAIN.  A search of the archives on "Daylight" revealed your solution to my problem:

On Feb 20, 2010, at 7:56 , Emmanuel LEVY wrote:

That's something Satimage.osax' "strftime" command can help with, look:

set dFeb to date "Saturday, February 20, 2010 4:51:07 PM"
set dSep to date "Monday, September 20, 2010 4:51:07 PM"

strftime dFeb into "%FT%TZ" with GMT
"2010-02-20T15:51:07Z"

strftime dSep into "%FT%TZ" with GMT
"2010-09-20T14:51:07Z"

In Satimage.osax, "with GMT" is really about the date then, not about now's GMT shift.

Emmanuel

I had been trying to detect when a date in an Excel spreadsheet is the same as a given date in an iCal calendar.  A straightforward compare works most of the time, except…

On Spring Forward day, 1am and 2am are the same time.  This befoozles AS.  I suppose something similar would happen on Fall Back day, when 1 am is two times.

Unexpected (and thus useless) results are in red.

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
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Daylight Savings Time
      • From: Emmanuel LEVY <email@hidden>
  • Prev by Date: Re: Puzzle Of the Day
  • Next by Date: Re: Daylight Savings Time
  • Previous by thread: Re: Puzzle Of the Day
  • Next by thread: Re: Daylight Savings Time
  • Index(es):
    • Date
    • Thread