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()); }
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)); }
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); }
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)); }
public object Clone() { JsTimeSpan obj = new JsTimeSpan(_value.Days, _value.Hours, _value.Minutes, _value.Seconds, _value.Milliseconds); return(obj); }
public void setTimeSpan(JsTimeSpan timespan) { _value = new TimeSpan(timespan.days, timespan.hours, timespan.minutes, timespan.seconds, timespan.milliseconds); }
public double differenceInDays(JsTimeSpan end) { JsTimeSpan d = differenceInTimeSpan(end); return(d.wholeDaysDecimal); }
public double differenceInMinutes(JsTimeSpan end) { JsTimeSpan d = differenceInTimeSpan(end); return(d.wholeMinutesDecimal); }
public double differenceInSeconds(JsTimeSpan end) { JsTimeSpan d = differenceInTimeSpan(end); return(d.wholeSecondsDecimal); }
public int differenceInMilliseconds(JsTimeSpan end) { JsTimeSpan d = differenceInTimeSpan(end); return(d.wholeMilliseconds); }
public void addTimeSpan(JsTimeSpan timespan) { _value.Add(new TimeSpan(timespan.days, timespan.hours, timespan.minutes, timespan.seconds, timespan.milliseconds)); }
public JsTimeSpan(JsTimeSpan value) { _value = value.Value; }