DateToDouble() публичный статический Метод

public static DateToDouble ( System.DateTime date ) : double
date System.DateTime
Результат double
Пример #1
0
        public override double ToNumber()
        {
            if (this.Value == null)
            {
                return(0.0);
            }
            if (!(this.Value is IConvertible))
            {
                return(double.NaN);
            }
            switch (Convert.GetTypeCode(this.Value))
            {
            case TypeCode.Boolean:
                return(JsBoolean.BooleanToNumber((bool)this.Value));

            case TypeCode.Char:
            case TypeCode.String:
                return(JsString.StringToNumber((string)this.Value));

            case TypeCode.DateTime:
                return(JsDate.DateToDouble((DateTime)this.Value));

            default:
                return(Convert.ToDouble(this.Value));
            }
        }
Пример #2
0
        public override double ToNumber()
        {
            if (Value == null)
            {
                return(0);
            }

            switch (Convert.GetTypeCode(Value))
            {
            case TypeCode.Boolean:
                return(JsBoolean.BooleanToNumber((bool)Value));

            case TypeCode.Char:
            case TypeCode.String:
                return(JsString.StringToNumber((string)Value));

            case TypeCode.DateTime:
                return(JsDate.DateToDouble((DateTime)Value));

            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.SByte:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64:
            case TypeCode.Decimal:
            case TypeCode.Double:
            case TypeCode.Single:
                return(Convert.ToDouble(Value));

            case TypeCode.Object:
                return(Convert.ToDouble(Value));

            case TypeCode.DBNull:
            case TypeCode.Empty:
            default:
                if (value is IConvertible)
                {
                    return(Convert.ToDouble(Value));
                }
                else
                {
                    return(double.NaN);
                }
            }
        }
Пример #3
0
        public override bool ToBoolean()
        {
            switch (Convert.GetTypeCode(Value))
            {
            case TypeCode.Boolean:
                return((bool)Value);

            case TypeCode.Char:
            case TypeCode.String:
                return(JsString.StringToBoolean((string)Value));

            case TypeCode.DateTime:
                return(JsNumber.NumberToBoolean(JsDate.DateToDouble((DateTime)Value)));

            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.Int32:
            case TypeCode.Int64:
            case TypeCode.SByte:
            case TypeCode.UInt16:
            case TypeCode.UInt32:
            case TypeCode.UInt64:
            case TypeCode.Decimal:
            case TypeCode.Double:
            case TypeCode.Single:
                return(JsNumber.NumberToBoolean((double)Value));

            case TypeCode.Object:
                return(Convert.ToBoolean(Value));

            case TypeCode.DBNull:
            case TypeCode.Empty:
            default:
                if (value is IConvertible)
                {
                    return(Convert.ToBoolean(Value));
                }
                else
                {
                    return(true);
                }
            }
        }
Пример #4
0
        public override bool ToBoolean()
        {
            if (this.Value != null && !(this.Value is IConvertible))
            {
                return(true);
            }
            switch (Convert.GetTypeCode(this.Value))
            {
            case TypeCode.Object:
                return(Convert.ToBoolean(this.Value));

            case TypeCode.Boolean:
                return((bool)this.Value);

            case TypeCode.Char:
            case TypeCode.String:
                return(JsString.StringToBoolean((string)this.Value));

            case TypeCode.SByte:
            case TypeCode.Byte:
            case TypeCode.Int16:
            case TypeCode.UInt16:
            case TypeCode.Int32:
            case TypeCode.UInt32:
            case TypeCode.Int64:
            case TypeCode.UInt64:
            case TypeCode.Single:
            case TypeCode.Double:
            case TypeCode.Decimal:
                return(JsNumber.NumberToBoolean(Convert.ToDouble(this.Value)));

            case TypeCode.DateTime:
                return(JsNumber.NumberToBoolean(JsDate.DateToDouble((DateTime)this.Value)));

            default:
                return(true);
            }
        }
Пример #5
0
 public override double ToNumber()
 {
     return(JsDate.DateToDouble(this.value));
 }