• 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 08:17:54 -0400

On Mon, May 24, 2010 at 8:00 AM, Luther Fuller <email@hidden> wrote:
Better yet, do this ...

set foo to current date
set {day of foo, year of foo, time of foo, month of foo} to {31, 2015, 0, October}
log foo -- OK
set {day of foo, year of foo, time of foo, month of foo} to {8, 2015, 0, February}
log foo --  OK

Sure,  but rearranging the order of the components doesn't help in general, as you can see by  swapping the above two lines:

set {day of foo, year of foo, time of foo, month of foo} to {8, 2015, 0, February}
log foo --  OK
set {day of foo, year of foo, time of foo, month of foo} to {31, 2015, 0, October}
log foo -- Not OK

As I said in my initial response, in the general case, you can't get around setting something twice, either the day or the month.  Even if you know exactly what the target date is - which you presumably do if the goal is to replace a literal string - you can't assume that a given sequence will work for any given "current date".

Probably the best thing is to do this logic once in a handler and then file and forget:

property defaultTime: {12, 0, 0}  -- noon; use {0,0,0} for midnight
to getDate(y, m, d)
    tell current date
        set {its hours, its minutes, its seconds} to defaultTime
        set its month to January
        set {its day, its year} to {d, y}
        set its month to m
        return it
    end tell
end getDate

--
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: LuKreme <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>)

  • Prev by Date: Re: Coping with Date format variations
  • Next by Date: Re: Problems importing the unix mailbox into Mail.app
  • Previous by thread: Re: Coping with Date format variations
  • Next by thread: Re: Coping with Date format variations
  • Index(es):
    • Date
    • Thread