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;
        }
Пример #2
0
 public Time AddSeconds(int second)
 {
     var result = new Time(_ticks.Add(new TimeSpan(0, 0, second)).Ticks);
     return CheckBound(result._ticks);
 }
Пример #3
0
 public Time AddMinutes(int min)
 {
     var result = new Time(_ticks.Add(new TimeSpan(0, min, 0)).Ticks);
     return CheckBound(result._ticks);
 }
Пример #4
0
 public Time AddHours(int hour)
 {
     var result = new Time(_ticks.Add(new TimeSpan(hour, 0, 0)).Ticks);
     return CheckBound(result._ticks);
 }