Re: date syntax not working on 10.10.5?
Re: date syntax not working on 10.10.5?
- Subject: Re: date syntax not working on 10.10.5?
- From: Shane Stanley <email@hidden>
- Date: Sat, 15 Aug 2015 09:34:35 +1000
On 15 Aug 2015, at 5:02 am, Michael Grant <email@hidden> wrote:
Well, for now I'm using the workaround:
date ((date string of (current date)) & " 10:15")
You're just leaving yourself open to more problems in future. The AppleScript Release Notes for 10.6 are pretty clear:
In AppleScript 2.1, the string must exactly match one of the system date formats (full, long, medium, or short; see System Preferences > International > Formats for examples), including all punctuation and whitespace. The only difference allowed is to use either a two- or four-digit year, regardless of what the format uses.
The fact that it still accepts some other strings may seem fortuitous, but it's just a bug waiting to happen. The notes continue: Some scripts used partial date specifiers as a way to get dates relative to the current date, such as date "1/31" for January 31 of the current year, or date "15" to get the 15th of the current month. To do this in AppleScript 2.1, get a base date and then set the desired components using the properties of the date object. For example, to get January 31 of the current year: set d to date "1/31/2000" | set year of d to year of (current date) | d --> date "Saturday, January 31, 2009 12:00:00 AM" |
Alternatively, start with current date as the base. To get the 15th of the current month: set d to current date | set day of d to 15 | set time of d to 0 | d --> date "Friday, May 15, 2009 12:00:00 AM" |
The latter is what Chris suggested.
|
_______________________________________________
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