• 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: Shane Stanley <email@hidden>
  • Date: Thu, 20 Aug 2015 09:44:25 +1000

On 20 Aug 2015, at 1:36 am, Michael Grant <email@hidden> wrote:
>
> *That* is the new and improved way to do
> date "10:15"

You're conflating two issues. If you are entering a value in a format that doesn't match the settings in preferences, you can't complain that it doesn't work after the developers specifically said not to do that. That it might have worked once is irrelevant: the limitation is clearly set out. Taking advantage of undocumented behavior is always a risk.

The second issue is that there's an inherent risk in converting from a string to a date when you can't control the format that will be used for that conversion. You're version of "control" might be that the scripts never leave your computer or your office, in which case fine -- but you're making your scripts reliant on something outside them. If you're happy with that, go for it -- as long as you understand the ramifications.

But you know the string's format, and in this case it's very basic, and you have the option to parse it yourself and never have to worry about the issue again. I was really suggesting that that's probably a more attractive option for many people.

Yes, it's more code. But you can write it once, stash it in a script library, and call it from there with barely a handful of extra keystrokes.

set dateString to "10:11"
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {":"}
set {theHours, theMinutes} to text items of dateString
set AppleScript's text item delimiters to saveTID
set theDate to current date
set time of theDate to theHours * hours + theMinutes * minutes


--
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


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

  • Prev by Date: Re: date syntax not working on 10.10.5?
  • 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