On GameSpot: Super Street Fighter IV confirmed!
BNET Business Network:
BNET
TechRepublic
ZDNet

November 3rd, 2009

Snow Leopard: Don't get caught in date handling change in AppleScript

Posted by David Morgenstern @ 6:49 am

Categories: 10.6, Snow Leopard

Tags: AppleScript, Scripting Languages, Software/Web Development, Web Development, David Morgenstern

As users migrate to Snow Leopard they will find that AppleScript is less forgiving about date and time formatting. Formerly reliable scripts, years old, may fail.

I was reminded of this change in a MacTech article by scripting consultant Ben Waldie, president of Automated Workflows and author of many books on AppleScript scripting.  (The article can be found in hardcopy in the latest issue of MacTech magazine, which is all about Snow Leopard. I bet that many will also appreciate the detailed rundown of changes to launchd in Snow Leopard by Greg Neagle at MacEnterprise.)

Waldie says that “coercions from strings to dates are also a bit finicky in Snow Leopard.” Previously, AppleScript was more forgiving in its handling of dates, he said. However, now date and times that ran correctly will either fail or work at the wrong time.

For example, if you had a script that ran at 5:00 a.m., it won’t run. It now needs to be formatted as AM. No periods allowed.

Waldie’s example pointed to a date string, 03, September, 2009, that produced an error. It wants to be September 3, 2009.

Here’s Waldie’s suggestion:

To prevent these types of errors, Apple recommends ensuring that any string being coerced to a date match one of the system date formats found in System Preferences, under Language and Text (formerly International)>Formats.

While professional scriptors are more focused on Snow Leopard’s significant changes to AppleScript Studio and Script Editor as well as the moving around of preferences and settings, the changes to date handling are serious to your data and workflow. They will catch the casual script writer and user unawares.

David MorgensternDavid Morgenstern has covered the Mac market and other technology segments for 20 years. See his full profile and disclosure of his industry affiliations.


Email David Morgenstern

Subscribe to The Apple Core via Email alerts or RSS.

  • Talkback
  • Most Recent of 1 Talkback(s)
Oh right...  Sleeper Service | 11/03/09

What do you think?

SponsoredWhite Papers, Webcasts, and Downloads

advertisement

Recent Entries

advertisement

Archives

Favorite Links

ZDNet Blogs

White Papers, Webcasts, and Downloads

Meet Doc