Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
 public Time AddSeconds(int second)
 {
     var result = new Time(_ticks.Add(new TimeSpan(0, 0, second)).Ticks);
     return CheckBound(result._ticks);
 }
Ejemplo n.º 3
0
 public Time AddMinutes(int min)
 {
     var result = new Time(_ticks.Add(new TimeSpan(0, min, 0)).Ticks);
     return CheckBound(result._ticks);
 }
Ejemplo n.º 4
0
 public Time AddHours(int hour)
 {
     var result = new Time(_ticks.Add(new TimeSpan(hour, 0, 0)).Ticks);
     return CheckBound(result._ticks);
 }