API.WebClients.TransitClient.RoundToNearestMinute C# (CSharp) Method

RoundToNearestMinute() private static method

private static RoundToNearestMinute ( System.TimeSpan source ) : System.TimeSpan
source System.TimeSpan
return System.TimeSpan
        private static TimeSpan RoundToNearestMinute(TimeSpan source)
        {
            // there are 10,000 ticks per millisecond, and 1000 milliseconds per second, and 60 seconds per minute
            const int TICKS_PER_MINUTE = 10000 * 1000 * 60;
            var subMinutesComponent = source.Ticks % TICKS_PER_MINUTE;

            return subMinutesComponent < TICKS_PER_MINUTE / 2
                ? source.Subtract(TimeSpan.FromTicks(subMinutesComponent))
                : source.Add(TimeSpan.FromTicks(TICKS_PER_MINUTE - subMinutesComponent));
        }