public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) { ValueProviderResult value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName); string attemptedValue = value.AttemptedValue; string format = !String.IsNullOrEmpty(bindingContext.ModelMetadata.DisplayFormatString) ? bindingContext.ModelMetadata.DisplayFormatString : "HH:mm:ss tt"; DateTime datetime = ToDateTime(attemptedValue, format); var time = new Time(datetime.Hour, datetime.Minute, datetime.Second); Type type = bindingContext.ModelType; if (!type.IsGenericType) { return time; } Time? t = time; return t; }
public Time AddSeconds(int second) { var result = new Time(_ticks.Add(new TimeSpan(0, 0, second)).Ticks); return CheckBound(result._ticks); }
public Time AddMinutes(int min) { var result = new Time(_ticks.Add(new TimeSpan(0, min, 0)).Ticks); return CheckBound(result._ticks); }
public Time AddHours(int hour) { var result = new Time(_ticks.Add(new TimeSpan(hour, 0, 0)).Ticks); return CheckBound(result._ticks); }