That’s my fault. The scripting dictionary says that the value for the in
parameter should be a record
. Instead, I specified a database
. What does work is
const sel = app.search('type:markdown', {in: app.databases['Personal'].root()});
The root
property is the top-level group of the database and a record
(in the DT sense).
Goodness, that’s slooooow. The code you tried to run was this
var date = new Date("2018-01-06 09:46:08 -0800");
console.log(date);
That code runs ok in Firefox and Chrome. It throws an “invalid date” error in Safari and Script Editor. This behavior is perfectly ok. As the MDN documentation on the constructor of the Date
class says:
The JavaScript specification only specifies one format to be universally supported: the date time string format, a simplification of the ISO 8601 calendar date extended format. The format is as follows:
YYYY-MM-DDTHH:mm:ss.sssZ
And further down it says:
You are encouraged to make sure your input conforms to the date time string format above for maximum compatibility, because support for other formats is not guaranteed.
So, Safari and Script Editor behave correctly. Chrome and Firefox are more forgiving in that they support laxer date strings like the one you provided.
I suggest always checking the documentation at MDN when you run into an error on one platform but not on the other. Apple’s JavaScript implementation is, in my experience, quite up-to-date and close to the standard – much more than Safari’s HTML/CSS implementation. If they decide not to implement more than required, that’s perfectly fine, IMO.