Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
974 B

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #include "tier1/strtools.h"
  8. #include "vmpi_browser_helpers.h"
  9. void FormatTimeString( unsigned long nInputSeconds, char *timeStr, int outLen )
  10. {
  11. // Make a string to say how long the thing has been running.
  12. unsigned long minutes = nInputSeconds / 60;
  13. unsigned long nSeconds = nInputSeconds - minutes * 60;
  14. unsigned long hours = minutes / 60;
  15. minutes -= hours * 60;
  16. unsigned long days = hours / 24;
  17. hours -= days * 24;
  18. if ( days && hours )
  19. {
  20. Q_snprintf( timeStr, outLen, "%dd %dh %dm", days, hours, minutes );
  21. }
  22. else if ( hours )
  23. {
  24. Q_snprintf( timeStr, outLen, "%dh %dm", hours, minutes );
  25. }
  26. else if ( minutes )
  27. {
  28. Q_snprintf( timeStr, outLen, "%dm %ds", minutes, nSeconds );
  29. }
  30. else
  31. {
  32. Q_snprintf( timeStr, outLen, "%d seconds", nSeconds );
  33. }
  34. }