TimeClip() static private method

static private TimeClip ( double time ) : double
time double
return double
Ejemplo n.º 1
0
        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)))));
        }
Ejemplo n.º 3
0
        public static double UTC(Object year, Object month, Object date, Object hours, Object minutes, Object seconds, Object ms)
        {
            if (year is Missing)
            {
                return(DateTime.Now.ToUniversalTime().Ticks / DatePrototype.ticksPerMillisecond - DatePrototype.msTo1970);
            }
            double dyear    = Convert.ToNumber(year);
            double dmonth   = month   is Missing ? 0 : Convert.ToNumber(month);
            double ddate    = date    is Missing ? 1 : Convert.ToNumber(date);
            double dhours   = hours   is Missing ? 0 : Convert.ToNumber(hours);
            double dminutes = minutes is Missing ? 0 : Convert.ToNumber(minutes);
            double dseconds = seconds is Missing ? 0 : Convert.ToNumber(seconds);
            double dms      = ms      is Missing ? 0 : Convert.ToNumber(ms);
            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(DatePrototype.TimeClip(DatePrototype.MakeDate(day, time)));
        }
        public static double UTC(object year, object month, object date, object hours, object minutes, object seconds, object ms)
        {
            if (year is Missing)
            {
                return((((double)DateTime.Now.ToUniversalTime().Ticks) / 10000.0) - 62135596800000);
            }
            double val  = Microsoft.JScript.Convert.ToNumber(year);
            double num2 = (month is Missing) ? 0.0 : Microsoft.JScript.Convert.ToNumber(month);
            double num3 = (date is Missing) ? 1.0 : Microsoft.JScript.Convert.ToNumber(date);
            double hour = (hours is Missing) ? 0.0 : Microsoft.JScript.Convert.ToNumber(hours);
            double min  = (minutes is Missing) ? 0.0 : Microsoft.JScript.Convert.ToNumber(minutes);
            double sec  = (seconds is Missing) ? 0.0 : Microsoft.JScript.Convert.ToNumber(seconds);
            double num7 = (ms is Missing) ? 0.0 : Microsoft.JScript.Convert.ToNumber(ms);
            int    num8 = (int)Runtime.DoubleToInt64(val);

            if ((!double.IsNaN(val) && (0 <= num8)) && (num8 <= 0x63))
            {
                val = num8 + 0x76c;
            }
            double day  = DatePrototype.MakeDay(val, num2, num3);
            double time = DatePrototype.MakeTime(hour, min, sec, num7);

            return(DatePrototype.TimeClip(DatePrototype.MakeDate(day, time)));
        }