Can't Coerce String to Date?
Can't Coerce String to Date?
- Subject: Can't Coerce String to Date?
- From: Alex Hall <email@hidden>
- Date: Fri, 13 Mar 2015 11:37:36 -0400
Hi list, The reason is kind of long, but suffice it to say that when I need a date in a script, it has to be in a dictionary format so I can pull out specific pieces. To do this, I have a handler that takes a date object and hands me my dictionary. Using NSDates is causing problems, though. NSDateFormatter isn't really an option, again because of the way this script works and what it does, and it seems a waste to set up NSDateComponents (not to mention I can't figure out how to OR together the masks to get the information I want).
Now that my newest script uses NSDates, I'm trying to give those to this handler. Of course it won't work directly, so I need to put the NSDate into the AppleScript date type. I thought it would be easy:
set startDateString to (e's startDate()'s |description|()) as text set startDate to (word 2 of startDateString & "/" & word 3 of startDateString & "/" & word 1 of startDateString) as date
In that snippet, "e" is an EKEvent. I don't get an error requesting e's date; rather I get an error that "can't convert "03/20/2015" to date". Yet, according to Google, AS can easily convert a string like that. The time will be midnight, but I can add the time in once this part is working. What am I doing wrong, or did something change because I'm using Yosemite and/or scripting additions?
--
Have a great day, Alex Hall
|
_______________________________________________
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