• 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: Coping with Date format variations
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Coping with Date format variations


  • Subject: Re: Coping with Date format variations
  • From: "Mark J. Reed" <email@hidden>
  • Date: Mon, 24 May 2010 16:39:29 -0400

On Mon, May 24, 2010 at 4:03 PM, LuKreme <email@hidden> wrote:
Just to be sure I understand all of this, you could set the month to January, March, May, July, August, or October? Is December also safe?

Yes.  

The root  issue here is that there are only two ways to get a date object in AppleScript: 'current date' and 'date "date string"'.  Of these, only the former is universal; the latter is subject to locale settings on the computer where the script is compiled.  

So if you want to construct a date object for an arbitrary date without worrying about locale settings, you have to start with (current date), which could of course be anything depending upon when the script is run.

If current date is in June and you set the day property to 31, poof!  The month property is reset to July.

If the current date is the 30th and you set the month property to February, poof!  The day property is now set to 1 or 2 (depending on whether the year property refers to a leap year!).

And there is no way to set these properties all at once.  Even a single list assignment ("set {month, day, year} to ...") sets them one at a time in left to right order, correcting each time.

To make the date object safe for such field-at-a-time modification, you must first either set the month to one that works with any legal day number, or set the day number to one that works with any month.  To meet these criteria you can set the month to any 31-day month (January, March, May, July, August, October, or December), or set the day to any number between 1 and 28 inclusive.

--
Mark J. Reed <email@hidden>

 _______________________________________________
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: Coping with Date format variations
      • From: Luther Fuller <email@hidden>
References: 
 >Re: Coping with Date format variations (From: Shane Stanley <email@hidden>)
 >Re: Coping with Date format variations (From: Luther Fuller <email@hidden>)
 >Re: Coping with Date format variations (From: "Mark J. Reed" <email@hidden>)
 >Re: Coping with Date format variations (From: LuKreme <email@hidden>)

  • Prev by Date: [ann] Learn AppleScript, 3rd edition now available
  • Next by Date: Re: Coping with Date format variations
  • Previous by thread: Re: Coping with Date format variations
  • Next by thread: Re: Coping with Date format variations
  • Index(es):
    • Date
    • Thread