Re: Coping with Date format variations
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:
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