• 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
Re: class reference "date" problems
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: class reference "date" problems


  • Subject: Re: class reference "date" problems
  • From: Shane Stanley <email@hidden>
  • Date: Thu, 07 May 2015 09:50:53 +1000

Coming in late...

On 24 Apr 2015, at 7:58 am, has <email@hidden> wrote:
>
> AppleScript dates do not support timezone information; they always assume the local timezone. (Yes, they are rubbish. Ancient classic MacOS date/time routines, unfortunately.) If you care about timezone info, you'll need to use Cocoa's NSDate class via the AS-ObjC bridge.

Why the two aren't bridged, I can't fathom, but it does make it more work than it should be, especially if you're dealing with things like dates within lists and records. Or you can use my ASObjCExtras.framework <http://www.macosxautomation.com/applescript/apps/ASObjCExtras.html> to make bridging semi-automatic (among other things; it can also do the same thing for aliases/files and NSURLs).
>
> One other thing: if you want to construct AppleScript date objects reliably in a non-locale-dependent way, use the following handler:
>
> on makeDate(y, m, d, hr, min, sec)
>    set newDate to current date
>    tell newDate to set {its year, its month, its day, its time} to {y, m, d, hr * hours + min * minutes + sec}
>    return newDate
> end makeDate

Just don't try that with a date BC.

--
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>


 _______________________________________________
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


  • Prev by Date: Re: find text in Acrobat
  • Next by Date: Re: class reference "date" problems
  • Previous by thread: Re: find text in Acrobat
  • Next by thread: Re: class reference "date" problems
  • Index(es):
    • Date
    • Thread