• 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: "Stockly, Ed" <email@hidden>
  • Date: Thu, 20 Aug 2015 01:13:04 +0000
  • Thread-topic: date syntax not working on 10.10.5?

Hey, Michael, see if this works for you:


set x to date string of (current date) & " " & "13:11" & "am"


date x


--date "Wednesday, August 19, 2015 at 1:11:00 PM"



That's a valid issue, but it's not quite the issue here. Let's assume there was such a format -- say yyyy-MM-dd hh:mm:ss. That's not going to deal with Michael's problem, because he wants to use "10:11", and he's expecting some rule to understand that he means the hh:mm part (and not mm:ss), and that he wants the rest of the values filled in with the values of now.

That's a perfectly good format.*

If there was such a format always available  you could do:
Set x  to (universal date string of ( current date) & " " & "10:11" 

Date x

Assuming you could get the date and time separately, as you can now. And even then, I think appleScript and most date and time algorithms have been clever enough to not need the trailing seconds, by default. It still is. 

Any scripter would soon learn that xx:yy where xx is less than 24 and yy is less than 60, will always be hh:mm and if you want hh:mm:ss then xx:yy:zz and there would be no other context where the date or the time commands would apply to two or three number in a string separated by :

Similarly, if you get the command  date xx:yy appleScript should first convert that to time, following the the logic above, then since the command is date, not time, use the current date.

So, yes, with the very simple logic that AppleScript already uses or has used in the past, it should be able to very easily deal with Michael's problem. 

But not my problem.  My problem is that I get dates and times in a wide number of various formats, on scripts running on numerous macs, where the users are free to change their Macs' date and time preferences. 

I used to be able to do this:

Date "September 4"
Date "Fri., September 4"
Date "Fri. Sept. 4"
Date "Fri Sep 4"
Date "Sep. 4"
Date "Sept. 4"
Date "9/4"
Date "9/4/15"
Date "09/04/2015"
Date "9/4/2015"
 
And each would return the correct date. In fact, just I just jumped over to MacOS9, and pasted that into Scripter and got this on compile:

date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"
date "Friday, September 4, 2015 12:00:00 AM"

But in Script Debugger on OSX 10.10.4:
The commented lines would not compile, only the last three would 

--Date "September 4"

--Date "Fri., September 4"

--Date "Fri. Sept. 4"

--Date "Fri Sep 4"

--Date "Sep. 4"

--Date "Sept. 4"

--Date "9/4"

date "Friday, September 4, 2015 at 12:00:00 AM"

date "Friday, September 4, 2015 at 12:00:00 AM"

date "Friday, September 4, 2015 at 12:00:00 AM"


It looks like in order to get back the default and flawless behavior we had in Mac OS9 and earlier (System 7?) I'd have to either use your solution and define every time and date format I can think of, or figure out a way to parse a huge variety of strings into dates.

In the meantime I have to rely on users entering dates and that has introduces errors into what was an error free process.

* date "2015-09-04 10:15" funnily enough, this one did NOT compile in OS9. Nor does it compile in OS X 10.10.4

 _______________________________________________
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: Shane Stanley <email@hidden>
    • Re: date syntax not working on 10.10.5?
      • From: Yvan KOENIG <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: Shane Stanley <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: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Yvan KOENIG <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: 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: "Stockly, Ed" <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: "Stockly, Ed" <email@hidden>)
 >Re: date syntax not working on 10.10.5? (From: Shane Stanley <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