private static int SecFromTime(double time){ double result = Math.Floor(time / msPerSecond) % SecondsPerMinute; if (result < 0) result += SecondsPerMinute; return (int)result; }