summaryrefslogtreecommitdiff
path: root/utils/vmpi/vmpi_browser_helpers.cpp
diff options
context:
space:
mode:
authorFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
committerFluorescentCIAAfricanAmerican <[email protected]>2020-04-22 12:56:21 -0400
commit3bf9df6b2785fa6d951086978a3e66f49427166a (patch)
tree2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /utils/vmpi/vmpi_browser_helpers.cpp
downloadarchived-source-engine-2018-hl2-src-master.tar.xz
archived-source-engine-2018-hl2-src-master.zip
Diffstat (limited to 'utils/vmpi/vmpi_browser_helpers.cpp')
-rw-r--r--utils/vmpi/vmpi_browser_helpers.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/utils/vmpi/vmpi_browser_helpers.cpp b/utils/vmpi/vmpi_browser_helpers.cpp
new file mode 100644
index 0000000..fed826f
--- /dev/null
+++ b/utils/vmpi/vmpi_browser_helpers.cpp
@@ -0,0 +1,43 @@
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $NoKeywords: $
+//=============================================================================//
+
+#include "tier1/strtools.h"
+#include "vmpi_browser_helpers.h"
+
+
+
+void FormatTimeString( unsigned long nInputSeconds, char *timeStr, int outLen )
+{
+ // Make a string to say how long the thing has been running.
+ unsigned long minutes = nInputSeconds / 60;
+ unsigned long nSeconds = nInputSeconds - minutes * 60;
+
+ unsigned long hours = minutes / 60;
+ minutes -= hours * 60;
+
+ unsigned long days = hours / 24;
+ hours -= days * 24;
+
+ if ( days && hours )
+ {
+ Q_snprintf( timeStr, outLen, "%dd %dh %dm", days, hours, minutes );
+ }
+ else if ( hours )
+ {
+ Q_snprintf( timeStr, outLen, "%dh %dm", hours, minutes );
+ }
+ else if ( minutes )
+ {
+ Q_snprintf( timeStr, outLen, "%dm %ds", minutes, nSeconds );
+ }
+ else
+ {
+ Q_snprintf( timeStr, outLen, "%d seconds", nSeconds );
+ }
+}
+
+