internal static void Init (IScriptable scope, bool zealed)
 {
     BuiltinDate obj = new BuiltinDate ();
     // Set the value of the prototype Date to NaN ('invalid date');
     obj.date = double.NaN;
     obj.ExportAsJSClass (MAX_PROTOTYPE_ID, scope, zealed
         , ScriptableObject.DONTENUM | ScriptableObject.READONLY | ScriptableObject.PERMANENT);
 }
        /* the javascript constructor */
        private static object jsConstructor (object [] args)
        {
            BuiltinDate obj = new BuiltinDate ();

            // if called as a constructor with no args,
            // return a new Date with the current time.
            if (args.Length == 0) {
                obj.date = now ();
                return obj;
            }

            // if called with just one arg -
            if (args.Length == 1) {
                object arg0 = args [0];
                if (arg0 is IScriptable)
                    arg0 = ((IScriptable)arg0).GetDefaultValue (null);
                double date;
                if (arg0 is string) {
                    // it's a string; parse it.
                    date = date_parseString ((string)arg0);
                }
                else {
                    // if it's not a string, use it as a millisecond date
                    date = ScriptConvert.ToNumber (arg0);
                }
                obj.date = TimeClip (date);
                return obj;
            }

            // multiple arguments; year, month, day etc.
            double [] array = new double [MAXARGS];
            int loop;
            double d;

            for (loop = 0; loop < MAXARGS; loop++) {
                if (loop < args.Length) {
                    d = ScriptConvert.ToNumber (args [loop]);

                    if (double.IsNaN (d) || System.Double.IsInfinity (d)) {
                        obj.date = double.NaN;
                        return obj;
                    }
                    array [loop] = ScriptConvert.ToInteger (args [loop]);
                }
                else {
                    array [loop] = 0;
                }
            }

            /* adjust 2-digit years into the 20th century */
            if (array [0] >= 0 && array [0] <= 99)
                array [0] += 1900;

            /* if we got a 0 for 'date' (which is out of range)
            * pretend it's a 1 */
            if (array [2] < 1)
                array [2] = 1;

            double day = MakeDay (array [0], array [1], array [2]);
            double time = MakeTime (array [3], array [4], array [5], array [6]);
            time = MakeDate (day, time);
            time = internalUTC (time);
            obj.date = TimeClip (time);

            return obj;
        }