예제 #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());
 }
예제 #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));
 }
예제 #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);
        }
예제 #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));
 }
예제 #5
0
        public object Clone()
        {
            JsTimeSpan obj = new JsTimeSpan(_value.Days, _value.Hours, _value.Minutes, _value.Seconds, _value.Milliseconds);

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

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

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

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

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