Пример #1
0
 public void Validate()
 {
     Hour.ValidateRequired("Hour");
     Minute.ValidateRequired("Minute");
     Second.ValidateOptional("Second");
     Millisecond.ValidateOptional("Millisecond");
 }
Пример #2
0
        public TimeSpan ToTimeSpan()
        {
            if (HasSecond && HasMillisecond)
            {
                return(new TimeSpan(
                           0,
                           Hour.ValueOrDefault(),
                           Minute.ValueOrDefault(),
                           Second.ValueOrDefault(),
                           Millisecond.ValueOrDefault()));
            }

            if (HasSecond)
            {
                return(new TimeSpan(Hour.Value, Minute.Value, Second.Value));
            }

            return(new TimeSpan(Hour.ValueOrDefault(), Minute.ValueOrDefault(), 0));
        }
Пример #3
0
 public Time(int hour, int minute, int second, int milliseconds)
 {
     if (hour >= 0)
     {
         Hour = new Hour(hour);
     }
     if (minute >= 0)
     {
         Minute = new Minute(minute);
     }
     if (second >= 0)
     {
         Second = new Second(second);
     }
     if (milliseconds >= 0)
     {
         Millisecond = new Millisecond(milliseconds);
     }
 }