Inheritance: IdScriptableObject
Example #1
0
		internal static void Init(Scriptable scope, bool @sealed)
		{
			Rhino.NativeDate obj = new Rhino.NativeDate();
			// Set the value of the prototype Date to NaN ('invalid date');
			obj.date = ScriptRuntime.NaN;
			obj.ExportAsJSClass(MAX_PROTOTYPE_ID, scope, @sealed);
		}
Example #2
0
		private static object JsConstructor(object[] args)
		{
			Rhino.NativeDate obj = new Rhino.NativeDate();
			// 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 Scriptable)
				{
					arg0 = ((Scriptable)arg0).GetDefaultValue(null);
				}
				double date;
				if (arg0 is CharSequence)
				{
					// it's a string; parse it.
					date = Date_parseString(arg0.ToString());
				}
				else
				{
					// if it's not a string, use it as a millisecond date
					date = ScriptRuntime.ToNumber(arg0);
				}
				obj.date = TimeClip(date);
				return obj;
			}
			double time = Date_msecFromArgs(args);
			if (!double.IsNaN(time) && !System.Double.IsInfinity(time))
			{
				time = TimeClip(InternalUTC(time));
			}
			obj.date = time;
			return obj;
		}