public virtual string Convert(TimeOnly time, ClockNotationRounding roundToNearestFive)
        {
            var normalizedMinutes = (int)(roundToNearestFive == ClockNotationRounding.NearestFiveMinutes
                ? 5 * Math.Round(time.Minute / 5.0)
                : time.Minute);

            return(normalizedMinutes switch
            {
                00 => GetHourExpression(time.Hour),
                60 => GetHourExpression(time.Hour + 1),
                _ => $"{GetHourExpression(time.Hour)} {normalizedMinutes.ToWords(GrammaticalGender.Feminine)}"
            });
Exemple #2
0
 public virtual string Convert(TimeOnly time, ClockNotationRounding roundToNearestFive)
 {
     switch (time)
     {
     case { Hour: 0, Minute : 0 } :
Exemple #3
0
 /// <summary>
 /// Turns the provided time into clock notation
 /// </summary>
 /// <param name="input">The time to be made into clock notation</param>
 /// <param name="roundToNearestFive">Whether to round the minutes to the nearest five or not</param>
 /// <returns>The time in clock notation</returns>
 public static string ToClockNotation(this TimeOnly input, ClockNotationRounding roundToNearestFive = ClockNotationRounding.None)
 {
     return(Configurator.TimeOnlyToClockNotationConverter.Convert(input, roundToNearestFive));
 }