summaryrefslogtreecommitdiff
path: root/utils/vmpi/vmpi_browser_helpers.cpp
blob: fed826f0d487e03582aadc8631e0d6648445c4f1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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 );
	}		
}