gregjsmith wrote:I have a variable in Indigo that I am trying to convert to a date. Here is the code:
- Code: Select all
set last_rain to date (value of variable "WMlastrain")
The script editor will pop back with a dialog saying : Indigo got an error: Can't get date "Monday, Oct 20, 2003 4:04:06 PM".
Even if I
- Code: Select all
set somevar to value of variable "WMlastrain" as string
then try to create a date from that I get the same error. What am I doing wrong?
The problem is there is no built-in AppleScript function to coerce a string into a date. When compiling scripts hard coded time/date strings are automatically converted to date objects (you'll notice the format of the string changes based on your system time/date format prefs), but during runtime there isn't an automatic way to say, "convert this string (or variable holding a string) into a date."
I seem to recall seeing a AppleScript function that someone wrote to help handle this. I googled for it but didn't see it anywhere. Anyone have any code snippets to help with this?
regards,
matt