• 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: date syntax not working on 10.10.5?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: date syntax not working on 10.10.5?


  • Subject: Re: date syntax not working on 10.10.5?
  • From: Michael Grant <email@hidden>
  • Date: Tue, 18 Aug 2015 14:15:01 -0500

Does this mean I'm going to have to futz around with TIDs just to get reliable date and time handling? What a pain — I thought the whole point of computer languages in general was to abstract that sort of thing. Why would Apple take that kind of big step backwards? Particularly since "10:15" without AM or PM actually *does* conform precisely to my short date string format in Language & Region preferences.

Michael

On Fri, Aug 14, 2015 at 6:34 PM, Shane Stanley <email@hidden> wrote:
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.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>


 _______________________________________________
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



--
There's really no such thing as translating. It's all a scam. We basically just make stuff up and try to make it sound plausible.
 _______________________________________________
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: date syntax not working on 10.10.5?
      • From: Christopher Stone <email@hidden>
    • Re: date syntax not working on 10.10.5?
      • From: "Stockly, Ed" <email@hidden>
    • Re: date syntax not working on 10.10.5?
      • From: Yvan KOENIG <email@hidden>
References: 
 >date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Christopher Stone <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Michael Grant <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: How do we Convert PICT to JPEG
  • Next by Date: Re: date syntax not working on 10.10.5?
  • Previous by thread: Re: date syntax not working on 10.10.5?
  • Next by thread: Re: date syntax not working on 10.10.5?
  • Index(es):
    • Date
    • Thread