Esempio n. 1
0
 // Return the tick count corresponding to the given hour, minute, second.
 // Will check the if the parameters are valid.
 internal static long TimeToTicks(int hour, int minute, int second, int millisecond)
 {
     if (hour >= 0 && hour < 24 && minute >= 0 && minute < 60 && second >= 0 && second < 60)
     {
         if (millisecond < 0 || millisecond >= MillisPerSecond)
         {
             throw new ArgumentOutOfRangeException(
                       nameof(millisecond),
                       String.Format(
                           CultureInfo.InvariantCulture,
                           SR.Format(SR.ArgumentOutOfRange_Range, 0, MillisPerSecond - 1)));
         }
         return(InternalGlobalizationHelper.TimeToTicks(hour, minute, second) + millisecond * TicksPerMillisecond);
     }
     throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadHourMinuteSecond);
 }
Esempio n. 2
0
 // Return the tick count corresponding to the given hour, minute, second.
 // Will check the if the parameters are valid.
 internal static long TimeToTicks(int hour, int minute, int second, int millisecond)
 {
     //TimeSpan.TimeToTicks is a family access function which does no error checking, so
     //we need to put some error checking out here.
     if (hour >= 0 && hour < 24 && minute >= 0 && minute < 60 && second >= 0 && second < 60)
     {
         if (millisecond < 0 || millisecond >= MillisPerSecond)
         {
             throw new ArgumentOutOfRangeException(
                       nameof(millisecond),
                       SR.Format(
                           SR.ArgumentOutOfRange_Range,
                           0,
                           MillisPerSecond - 1));
         }
         return(InternalGlobalizationHelper.TimeToTicks(hour, minute, second) + millisecond * TicksPerMillisecond);;
     }
     throw new ArgumentOutOfRangeException(null, SR.ArgumentOutOfRange_BadHourMinuteSecond);
 }