public new DateObject CreateInstance(params Object[] args) { if (args.Length == 0) { return(new DateObject(this.originalPrototype, DateTime.Now.ToUniversalTime().Ticks / DatePrototype.ticksPerMillisecond - DatePrototype.msTo1970)); } if (args.Length == 1) { Object arg0 = args[0]; IConvertible ic = Convert.GetIConvertible(arg0); TypeCode tcode = Convert.GetTypeCode(arg0, ic); if (tcode == TypeCode.DateTime) { return(new DateObject(this.originalPrototype, ic.ToDateTime(null).ToUniversalTime().Ticks / DatePrototype.ticksPerMillisecond - DatePrototype.msTo1970)); } Object yv = Convert.ToPrimitive(arg0, PreferredType.Either, ref ic); if (Convert.GetTypeCode(yv, ic) == TypeCode.String) { return(new DateObject(this.originalPrototype, parse(ic.ToString(null)))); } double d = Convert.ToNumber(yv, ic); if (DatePrototype.minDate <= d && d <= DatePrototype.maxDate) { return(new DateObject(this.originalPrototype, d)); } return(new DateObject(this.originalPrototype, Double.NaN)); } double dyear = Convert.ToNumber(args[0]); double dmonth = Convert.ToNumber(args[1]); double ddate = (args.Length > 2) ? Convert.ToNumber(args[2]) : 1; double dhours = (args.Length > 3) ? Convert.ToNumber(args[3]) : 0; double dminutes = (args.Length > 4) ? Convert.ToNumber(args[4]) : 0; double dseconds = (args.Length > 5) ? Convert.ToNumber(args[5]) : 0; double dms = (args.Length > 6) ? Convert.ToNumber(args[6]) : 0; int y = (int)dyear; if (!Double.IsNaN(dyear) && 0 <= y && y <= 99) { dyear = y + 1900; } double day = DatePrototype.MakeDay(dyear, dmonth, ddate); double time = DatePrototype.MakeTime(dhours, dminutes, dseconds, dms); return(new DateObject(this.originalPrototype, DatePrototype.TimeClip(DatePrototype.UTC(DatePrototype.MakeDate(day, time))))); }
public DateObject CreateInstance(params object[] args) { if (args.Length == 0) { return(new DateObject(this.originalPrototype, (((double)DateTime.Now.ToUniversalTime().Ticks) / 10000.0) - 62135596800000)); } if (args.Length == 1) { object ob = args[0]; IConvertible iConvertible = Microsoft.JScript.Convert.GetIConvertible(ob); if (Microsoft.JScript.Convert.GetTypeCode(ob, iConvertible) == TypeCode.DateTime) { return(new DateObject(this.originalPrototype, (((double)iConvertible.ToDateTime(null).ToUniversalTime().Ticks) / 10000.0) - 62135596800000)); } object obj3 = Microsoft.JScript.Convert.ToPrimitive(ob, PreferredType.Either, ref iConvertible); if (Microsoft.JScript.Convert.GetTypeCode(obj3, iConvertible) == TypeCode.String) { return(new DateObject(this.originalPrototype, parse(iConvertible.ToString(null)))); } double num = Microsoft.JScript.Convert.ToNumber(obj3, iConvertible); if ((-8.64E+15 <= num) && (num <= 8.64E+15)) { return(new DateObject(this.originalPrototype, num)); } return(new DateObject(this.originalPrototype, double.NaN)); } double val = Microsoft.JScript.Convert.ToNumber(args[0]); double month = Microsoft.JScript.Convert.ToNumber(args[1]); double date = (args.Length > 2) ? Microsoft.JScript.Convert.ToNumber(args[2]) : 1.0; double hour = (args.Length > 3) ? Microsoft.JScript.Convert.ToNumber(args[3]) : 0.0; double min = (args.Length > 4) ? Microsoft.JScript.Convert.ToNumber(args[4]) : 0.0; double sec = (args.Length > 5) ? Microsoft.JScript.Convert.ToNumber(args[5]) : 0.0; double ms = (args.Length > 6) ? Microsoft.JScript.Convert.ToNumber(args[6]) : 0.0; int num9 = (int)Runtime.DoubleToInt64(val); if ((!double.IsNaN(val) && (0 <= num9)) && (num9 <= 0x63)) { val = num9 + 0x76c; } double day = DatePrototype.MakeDay(val, month, date); double time = DatePrototype.MakeTime(hour, min, sec, ms); return(new DateObject(this.originalPrototype, DatePrototype.TimeClip(DatePrototype.UTC(DatePrototype.MakeDate(day, time))))); }