Exemple #1
0
 public override object CreateInstance(ITypeDescriptorContext context, System.Collections.IDictionary propertyValues)
 {
     if (propertyValues != null)
     {
         object v = null;
         if (propertyValues.Contains("value"))
         {
             v = propertyValues["value"];
         }
         if (v is JsTimeSpan)
         {
             return((JsTimeSpan)v);
         }
         JsTimeSpan ts = new JsTimeSpan();
         if (v != null)
         {
             if (v is string)
             {
                 string s = v as string;
                 if (!string.IsNullOrEmpty(s))
                 {
                     ts.parseTimeSpan(s);
                 }
             }
         }
         return(ts);
     }
     return(new JsTimeSpan());
 }
Exemple #2
0
 public JsTimeSpan differenceInTimeSpan(JsTimeSpan end)
 {
     if (end == null)
     {
         return(new JsTimeSpan(this));
     }
     return(new JsTimeSpan(this.days - end.days, this.hours - end.hours, this.minutes - end.minutes, this.seconds - end.seconds, this.milliseconds - end.milliseconds));
 }
Exemple #3
0
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            JsTimeSpan ts = new JsTimeSpan();

            if (value != null)
            {
                if (value is string)
                {
                    string s = value as string;
                    if (!string.IsNullOrEmpty(s))
                    {
                        ts.parseTimeSpan(s);
                    }
                }
                else
                {
                    return(base.ConvertFrom(context, culture, value));
                }
            }
            return(ts);
        }
Exemple #4
0
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (typeof(JsTimeSpan).IsAssignableFrom(destinationType))
     {
         JsTimeSpan ts = new JsTimeSpan();
         if (value != null)
         {
             if (value is string)
             {
                 string s = value as string;
                 if (!string.IsNullOrEmpty(s))
                 {
                     ts.parseTimeSpan(s);
                 }
             }
             else
             {
                 return(base.ConvertTo(context, culture, value, destinationType));
             }
         }
         return(ts);
     }
     if (typeof(string).Equals(destinationType))
     {
         if (value == null)
         {
             return(string.Empty);
         }
         JsTimeSpan jt = value as JsTimeSpan;
         if (jt != null)
         {
             return(jt.toWholeString());
         }
         return(value.ToString());
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
Exemple #5
0
        public object Clone()
        {
            JsTimeSpan obj = new JsTimeSpan(_value.Days, _value.Hours, _value.Minutes, _value.Seconds, _value.Milliseconds);

            return(obj);
        }
Exemple #6
0
 public void setTimeSpan(JsTimeSpan timespan)
 {
     _value = new TimeSpan(timespan.days, timespan.hours, timespan.minutes, timespan.seconds, timespan.milliseconds);
 }
Exemple #7
0
        public double differenceInDays(JsTimeSpan end)
        {
            JsTimeSpan d = differenceInTimeSpan(end);

            return(d.wholeDaysDecimal);
        }
Exemple #8
0
        public double differenceInMinutes(JsTimeSpan end)
        {
            JsTimeSpan d = differenceInTimeSpan(end);

            return(d.wholeMinutesDecimal);
        }
Exemple #9
0
        public double differenceInSeconds(JsTimeSpan end)
        {
            JsTimeSpan d = differenceInTimeSpan(end);

            return(d.wholeSecondsDecimal);
        }
Exemple #10
0
        public int differenceInMilliseconds(JsTimeSpan end)
        {
            JsTimeSpan d = differenceInTimeSpan(end);

            return(d.wholeMilliseconds);
        }
Exemple #11
0
 public void addTimeSpan(JsTimeSpan timespan)
 {
     _value.Add(new TimeSpan(timespan.days, timespan.hours, timespan.minutes, timespan.seconds, timespan.milliseconds));
 }
Exemple #12
0
 public JsTimeSpan(JsTimeSpan value)
 {
     _value = value.Value;
 }