Subject: | |
From: | |
Reply To: | |
Date: | Fri, 28 Jun 2013 23:16:47 +1000 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
On 28/06/2013, at 10:04 PM, Mark Lively <[log in to unmask]> wrote:
> If you are will to dive into ASOC (Applescript Objective C) aka Cocoa AppleScript the following works.
Almost...
> set aDate to NSDate's dateWithTimeIntervalSinceNow_((date "Friday, January 1, 1904 12:00:00 AM") - (current date))
That's not reliable because of daylight savings time. You need to convert from AS dates to NSDates with something like (adjust date string to match your settings):
on makeNSDateFrom_(theASDate)
set refDate to date "Friday, 1 January 1904 0:00:00" as date
set theDiff to theASDate - refDate - 3.061152E+9 - (time to GMT) + (current application's NSTimeZone's localTimeZone()'s daylightSavingTimeOffset()) as real
set newDate to current application's NSDate's dateWithTimeIntervalSinceReferenceDate_(theDiff)
return newDate
end makeNSDateFrom_
> Remembers when time began in 1904, now time begins in 1970.
You're behind the times. Cocoa time begins in 2001.
--
Shane Stanley <[log in to unmask]>
'AppleScriptObjC Explored' <www.macosxautomation.com/applescript/apps/>
|
|
|