aboutsummaryrefslogtreecommitdiff
path: root/mp/src/common/replay/replaytime.h
blob: eb1c3295a850cdd71bd9bab8095c648c6ba5c726 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=======================================================================================//

#ifndef REPLAYTIME_H
#define REPLAYTIME_H
#ifdef _WIN32
#pragma once
#endif

//----------------------------------------------------------------------------------------

class KeyValues;

//----------------------------------------------------------------------------------------

#include "vgui/ILocalize.h"

//----------------------------------------------------------------------------------------

class CReplayTime
{
public:
	CReplayTime();

	void InitDateAndTimeToNow();

	void Read( KeyValues *pIn );
	void Write( KeyValues *pOut );

	// Modifiers:
	void SetDate( int nDay, int nMonth, int nYear );
	void SetTime( int nHour, int nMin, int nSec );
	inline void SetRawDate( int nRawDate )	{ m_fDate = nRawDate; }
	inline void SetRawTime( int nRawTime )	{ m_fTime = nRawTime; }

	// Accessors:
	void GetTime( int &nHour, int &nMin, int &nSec ) const;
	void GetDate( int &nDay, int &nMonth, int &nYear ) const;

	static const char *FormatTimeString( int nSecs );
	static const char *FormatPreciseTimeString( float flSecs );
	static const wchar_t *GetLocalizedMonth( vgui::ILocalize *pLocalize, int nMonth );
	static const wchar_t *GetLocalizedDay( vgui::ILocalize *pLocalize, int nDay );
	static const wchar_t *GetLocalizedYear( vgui::ILocalize *pLocalize, int nYear );
	static const wchar_t *GetLocalizedTime( vgui::ILocalize *pLocalize, int nHour, int nMin, int nSec );
	static const wchar_t *GetLocalizedDate( vgui::ILocalize *pLocalize, int nDay, int nMonth, int nYear,
		int *pHour = NULL, int *pMin = NULL, int *pSec = NULL, bool bForceFullFormat = false );	// bForceFullFormat true will keep from returning "today" or "yesterday"
	static const wchar_t *GetLocalizedDate( vgui::ILocalize *pLocalize, const CReplayTime &t, bool bForceFullFormat = false );

	int				m_fDate;		// Representation of a date (bitfield)
	int				m_fTime;		// Representation of time (bitfield)
};

//----------------------------------------------------------------------------------------

#endif // REPLAYTIME_H