Reputation: 1245
Is there any documentation for what I can do to an object created like "new Date()"? I thought it would be a Javascript date object, but it doesn't seem to have most of the methods of that object.
Thanks.
Upvotes: 3
Views: 2969
Reputation: 1059
I also ran into a Date related issue in Google Apps Script where Javascript in my browser console would correctly interpret a date (in the format "2014-08-26T11:25:01.000-0400"), but the GAS Date object would not and result in "Invalid Date".
I found this answer to another question where in a comment it was mentioned that GAS uses Rhino to interpret Javascript. I downloaded several versions of Rhino until I found one old enough that gave me the same error (Rhino 1.7R5, Jan. 29, 2015).
You can download that version and peruse the source code and even run the interpreter with a REPL using the command java -jar js.jar
. To answer your question, src/org/mozilla/javascript/NativeDate.java would be the file you're looking for, and the definition of the Date object is down near the bottom where a bunch of private static final int
s are declared (ex: Id_constructor, Id_toString, etc.) I think those ints correspond to methods in the same Java class that define the Javascript Date object.
Upvotes: 1