HudFormatting.cs 549 B

12345678910111213141516
  1. using System;
  2. using System.Globalization;
  3. namespace DevilLink2.UI
  4. {
  5. public static class HudFormatting
  6. {
  7. // Matches the final HTML updateTimer: ceil first, then minutes/seconds.
  8. public static string Time(bool hasTimer, double remaining)
  9. {
  10. if (!hasTimer) return "∞";
  11. long seconds = (long)Math.Ceiling(Math.Max(0, remaining));
  12. return (seconds / 60).ToString("00", CultureInfo.InvariantCulture) + ":" + (seconds % 60).ToString("00", CultureInfo.InvariantCulture);
  13. }
  14. }
  15. }