Esempio n. 1
0
 public JsInstance GetTimeImpl(JsDictionaryObject target, JsInstance[] parameters)
 {
     if (double.IsNaN(target.ToNumber()))
     {
         return(this.Global.NaN);
     }
     return((JsInstance)this.Global.NumberClass.New(target.ToNumber()));
 }
        /// <summary>
        /// 15.9.5.9
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance GetTimeImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.NaN);
            }

            return(Global.NumberClass.New(CreateDateTime(target.ToNumber()).TimeOfDay.Ticks / JsDate.TICKSFACTOR));
        }
Esempio n. 3
0
        /// <summary>
        /// 15.9.5.7
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance ToLocaleTimeStringImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.StringClass.New(double.NaN.ToString()));
            }

            return(Global.StringClass.New(CreateDateTime(target.ToNumber()).ToLocalTime().ToString(JsDate.TIMEFORMAT)));
        }
Esempio n. 4
0
        /// <summary>
        /// 15.9.5.8
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance ValueOfImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.NaN);
            }

            return(Global.NumberClass.New(target.ToNumber()));
        }
Esempio n. 5
0
        /// <summary>
        /// 15.9.5.17
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance GetUTCDayImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.NaN);
            }

            return(Global.NumberClass.New((int)CreateDateTime(target.ToNumber()).ToUniversalTime().DayOfWeek));
        }
Esempio n. 6
0
        /// <summary>
        /// 15.9.5.20
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance GetMinutesImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.NaN);
            }

            return(Global.NumberClass.New(CreateDateTime(target.ToNumber()).ToLocalTime().Minute));
        }
Esempio n. 7
0
        /// <summary>
        /// 15.9.5.
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance ToUTCStringImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.StringClass.New(double.NaN.ToString()));
            }

            return(Global.StringClass.New(CreateDateTime(target.ToNumber()).ToString(JsDate.FORMATUTC, CultureInfo.InvariantCulture)));
        }
Esempio n. 8
0
        /// <summary>
        /// 15.9.5.25
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance GetUTCMillisecondsImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.NaN);
            }

            return(Global.NumberClass.New(CreateDateTime(target.ToNumber()).ToUniversalTime().Millisecond));
        }
Esempio n. 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance ToLocaleStringImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.StringClass.New(double.NaN.ToString()));
            }

            return(Global.StringClass.New(CreateDateTime(target.ToNumber()).ToLocalTime().ToString("F", CultureInfo.CurrentCulture)));
        }
        /// <summary>
        /// 15.9.5.13
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance GetUTCMonthImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(Global.NaN);
            }

            return(Global.NumberClass.New(CreateDateTime(target.ToNumber()).Month - 1));
        }
Esempio n. 11
0
        public JsInstance GetSecondsImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(this.Global.NaN);
            }
            JsNumberConstructor numberClass = this.Global.NumberClass;
            DateTime            dateTime    = JsDateConstructor.CreateDateTime(target.ToNumber());

            dateTime = dateTime.ToLocalTime();
            double second = (double)dateTime.Second;

            return((JsInstance)numberClass.New(second));
        }
Esempio n. 12
0
        public JsInstance GetUTCHoursImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return(this.Global.NaN);
            }
            JsNumberConstructor numberClass = this.Global.NumberClass;
            DateTime            dateTime    = JsDateConstructor.CreateDateTime(target.ToNumber());

            dateTime = dateTime.ToUniversalTime();
            double hour = (double)dateTime.Hour;

            return((JsInstance)numberClass.New(hour));
        }
Esempio n. 13
0
        public JsInstance ToTimeStringImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return((JsInstance)this.Global.StringClass.New(double.NaN.ToString()));
            }
            JsStringConstructor stringClass = this.Global.StringClass;
            DateTime            dateTime    = JsDateConstructor.CreateDateTime(target.ToNumber());

            dateTime = dateTime.ToLocalTime();
            string str = dateTime.ToString(JsDate.TIMEFORMAT, (IFormatProvider)CultureInfo.InvariantCulture);

            return((JsInstance)stringClass.New(str));
        }
Esempio n. 14
0
        public JsInstance ToLocaleDateStringImpl(
            JsDictionaryObject target,
            JsInstance[] parameters)
        {
            if (double.IsNaN(target.ToNumber()))
            {
                return((JsInstance)this.Global.StringClass.New(double.NaN.ToString()));
            }
            JsStringConstructor stringClass = this.Global.StringClass;
            DateTime            dateTime    = JsDateConstructor.CreateDateTime(target.ToNumber());

            dateTime = dateTime.ToLocalTime();
            string str = dateTime.ToString(JsDate.DATEFORMAT);

            return((JsInstance)stringClass.New(str));
        }
Esempio n. 15
0
 public JsInstance ToUTCStringImpl(JsDictionaryObject target, JsInstance[] parameters)
 {
     if (double.IsNaN(target.ToNumber()))
     {
         return((JsInstance)this.Global.StringClass.New(double.NaN.ToString()));
     }
     return((JsInstance)this.Global.StringClass.New(JsDateConstructor.CreateDateTime(target.ToNumber()).ToString(JsDate.FORMATUTC, (IFormatProvider)CultureInfo.InvariantCulture)));
 }
Esempio n. 16
0
        public JsInstance SetUTCDateImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no date specified");
            }
            DateTime dateTime = JsDateConstructor.CreateDateTime(target.ToNumber());

            dateTime     = dateTime.AddDays((double)-dateTime.Day);
            dateTime     = dateTime.AddDays(parameters[0].ToNumber());
            target.Value = (object)dateTime;
            return((JsInstance)target);
        }
Esempio n. 17
0
        /// <summary>
        /// 15.9.5.37
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SetUTCDateImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no date specified");
            }
            DateTime valueOf = CreateDateTime(target.ToNumber());

            valueOf      = valueOf.AddDays(-valueOf.Day);
            valueOf      = valueOf.AddDays(parameters[0].ToNumber());
            target.Value = valueOf;
            return(target);
        }
Esempio n. 18
0
        /// <summary>
        /// 15.9.5.29
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SetUTCMillisecondsImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no millisecond specified");
            }

            DateTime valueOf = CreateDateTime(target.ToNumber());

            valueOf      = valueOf.AddMilliseconds(-valueOf.Millisecond);
            valueOf      = valueOf.AddMilliseconds(parameters[0].ToNumber());
            target.Value = New(valueOf).ToNumber();
            return(target);
        }
Esempio n. 19
0
        public JsInstance SetUTCMillisecondsImpl(
            JsDictionaryObject target,
            JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no millisecond specified");
            }
            DateTime dateTime = JsDateConstructor.CreateDateTime(target.ToNumber());

            dateTime     = dateTime.AddMilliseconds((double)-dateTime.Millisecond);
            dateTime     = dateTime.AddMilliseconds(parameters[0].ToNumber());
            target.Value = (object)this.New(dateTime).ToNumber();
            return((JsInstance)target);
        }
Esempio n. 20
0
        /// <summary>
        /// 15.9.5.35
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SetHoursImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no hour specified");
            }
            DateTime valueOf = CreateDateTime(target.ToNumber()).ToLocalTime();

            valueOf      = valueOf.AddHours(-valueOf.Hour);
            valueOf      = valueOf.AddHours(parameters[0].ToNumber());
            target.Value = valueOf;
            if (parameters.Length > 1)
            {
                JsInstance[] innerParams = new JsInstance[parameters.Length - 1];
                Array.Copy(parameters, 1, innerParams, 0, innerParams.Length);
                target = (JsDate)SetMinutesImpl(target, innerParams);
            }
            return(target);
        }
Esempio n. 21
0
        public JsInstance SetHoursImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no hour specified");
            }
            DateTime dateTime = JsDateConstructor.CreateDateTime(target.ToNumber()).ToLocalTime();

            dateTime     = dateTime.AddHours((double)-dateTime.Hour);
            dateTime     = dateTime.AddHours(parameters[0].ToNumber());
            target.Value = (object)dateTime;
            if (parameters.Length > 1)
            {
                JsInstance[] parameters1 = new JsInstance[parameters.Length - 1];
                parameters.CopyTo((Array)parameters1, 1);
                target = (JsDictionaryObject)this.SetMinutesImpl(target, parameters1);
            }
            return((JsInstance)target);
        }
Esempio n. 22
0
        public JsInstance SetUTCMonthImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no month specified");
            }
            DateTime dateTime = JsDateConstructor.CreateDateTime(target.ToNumber());

            dateTime     = dateTime.AddMonths(-dateTime.Month);
            dateTime     = dateTime.AddMonths((int)parameters[0].ToNumber());
            target.Value = (object)dateTime;
            if (parameters.Length > 1)
            {
                JsInstance[] parameters1 = new JsInstance[parameters.Length - 1];
                parameters.CopyTo((Array)parameters1, 1);
                target = (JsDictionaryObject)this.SetDateImpl(target, parameters1);
            }
            return((JsInstance)target);
        }
Esempio n. 23
0
        public JsInstance SetFullYearImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no year specified");
            }
            DateTime dateTime = JsDateConstructor.CreateDateTime(target.ToNumber()).ToLocalTime();
            int      num      = dateTime.Year - (int)parameters[0].ToNumber();

            dateTime     = dateTime.AddYears(-num);
            target.Value = (object)dateTime;
            if (parameters.Length > 1)
            {
                JsInstance[] parameters1 = new JsInstance[parameters.Length - 1];
                parameters.CopyTo((Array)parameters1, 1);
                target = (JsDictionaryObject)this.SetMonthImpl(target, parameters1);
            }
            return((JsInstance)target);
        }
Esempio n. 24
0
        /// <summary>
        /// 15.9.5.40
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SetFullYearImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no year specified");
            }
            DateTime valueOf = CreateDateTime(target.ToNumber()).ToLocalTime();
            int      diff    = valueOf.Year - (int)parameters[0].ToNumber();

            valueOf      = valueOf.AddYears(-diff);
            target.Value = valueOf;
            if (parameters.Length > 1)
            {
                JsInstance[] innerParams = new JsInstance[parameters.Length - 1];
                Array.Copy(parameters, 1, innerParams, 0, innerParams.Length);
                target = (JsDate)SetMonthImpl(target, innerParams);
            }
            return(target);
        }
Esempio n. 25
0
        /// <summary>
        /// 15.9.5.39
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SetUTCMonthImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no month specified");
            }
            DateTime valueOf = CreateDateTime(target.ToNumber());

            valueOf      = valueOf.AddMonths(-valueOf.Month);
            valueOf      = valueOf.AddMonths((int)parameters[0].ToNumber() + 1);
            target.Value = valueOf;
            if (parameters.Length > 1)
            {
                JsInstance[] innerParams = new JsInstance[parameters.Length - 1];
                Array.Copy(parameters, 1, innerParams, 0, innerParams.Length);
                target = (JsDate)SetDateImpl(target, innerParams);
            }
            return(target);
        }
        /// <summary>
        /// 15.9.5.34
        /// </summary>
        /// <param name="target"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public JsInstance SetUTCMinutesImpl(JsDictionaryObject target, JsInstance[] parameters)
        {
            if (parameters.Length == 0)
            {
                throw new ArgumentException("There was no minute specified");
            }
            DateTime valueOf = CreateDateTime(target.ToNumber());

            valueOf      = valueOf.AddMinutes(-valueOf.Minute);
            valueOf      = valueOf.AddMinutes(parameters[0].ToNumber());
            target.Value = valueOf;
            if (parameters.Length > 1)
            {
                JsInstance[] innerParams = new JsInstance[parameters.Length - 1];
                parameters.CopyTo(innerParams, 1);
                target = (JsDate)SetSecondsImpl(target, innerParams);
            }
            return(target);
        }