Am I the only one experiencing that the AS's environment is unstable?

I’m developing/testing a new script and therefore execute a lot. The first few lines of the script looks like this:

on run {}
	set startTime to current date
	log "Started: " & startTime

Obviously, they have worked fine for, probably, hundreds of launches. Suddenly I start to get this error when I launch this script:


error "\"Started: Tuesday, 13 February 2024 at 20:36:13\" doesn’t understand the “log” message." number -1708 from "Started: Tuesday, 13 February 2024 at 20:36:13"

Currently, I can’t execute this script because it fails on the third line - ONE of my three computers. This is not the first time this happens, see this thread.

I have three computers, running three different OS (Sonoma, Ventura and Big Sur) and they all have shown this behaviour at least once. The problem is permanent until it suddenly disappears again, after a week or a couple of weeks. I haven’t seen any pattern in this.

The only slightly “odd” thing in my setup is the uptime, both for the computers and Script Editor. Typically both the machine and SE are open for months at the time.

Am I really the only one experiencing this? If all three of my machines have this problem I think that someone else also should see this.

Your script snippet works fine for me.

I will say though that the other day while looking at a recent post on time zones, I was playing around with current date and did get that error although I don’t recall the exact context.

I think I resolved it by putting parentheses around the current date.

The current date command returns a date object, which should be coerced to text because it is preceded by text . I strongly suspect the issue lies elsewhere, but you might use the following just to eliminate this as a possible cause:

set startTime to (current date) as text
log "Started: " & startTime

I know that my snippet works. I have executed it literally hundreds of times, and it works on my two other computers. My question is if someone else experience that AS - the execution environment - is unstable? E.g., that scripts stop working until you restart your computer or similar.

Now, AppleScript’s date string has a strange behavior in macOS 14, Sonoma.

In English user environment, AppleScript’s date string include invisible strange character (x202F Narrow No-Break Space) between AM/PM mark.

http://piyocast.com/as/archives/15953

I met this strange behavior in macOS 14 with only 12-hour time notation (with AM/PM mark).

Each environment you tested might have various time notation setting.
And…check each date object logging.

use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

script spd
	property errorD : {}
end script

set errorD of spd to {}
set y to 2024

repeat with m from 1 to 12
	set mMax to getMlenInternational(y, m) of me
	
	repeat with d from 1 to mMax
		repeat with hourNum from 0 to 23
			repeat with minuteNum from 0 to 59
				--repeat with secondNum from 0 to 59
				set aDate to retDateOwithParam(y, m, d, hourNum, minuteNum, 0) of me
				try
					log "Started: " & aDate
				on error
					set the end of (errorD of spd) to (aDate as string)
				end try
				--end repeat
			end repeat
		end repeat
	end repeat
end repeat

return length of (errorD of spd)


on getMlenInternational(aYear, aMonth)
	set sDat to retDateOwithParam(aYear, aMonth, 1, 0, 0, 0) of me
	if aMonth is not equal to 12 then
		set eDat to retDateOwithParam(aYear, aMonth + 1, 1, 0, 0, 0) of me
	else
		set eDat to retDateOwithParam(aYear + 1, 1, 1, 0, 0, 0) of me
	end if
	
	set eDat to eDat - 1
	
	set mLen to day of eDat
	
	return mLen
end getMlenInternational


on retDateOwithParam(yearNum, monthNum, dateNum, hourNum, minuteNum, secondNum)
	set curDate to current date
	tell (curDate)
		copy {yearNum, monthNum, dateNum, hourNum, minuteNum, secondNum} to {year of it, month of it, day of it, hours of it, minutes of it, seconds of it}
	end tell
	return curDate
end retDateOwithParam