1 /* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
2 
3 #ifndef TIME_UTIL_H
4 #define TIME_UTIL_H
5 
6 #include <string>
7 #include <ctime>
8 
9 #ifdef __GNUC__
10 #define __time64_t time_t
11 #define _time64(x) time(x)
12 #define _localtime64(x) localtime(x)
13 #endif
14 
15 class CTimeUtil
16 {
17 public:
18 	/**
19 	 * Returns the current time as a long integer
20 	 */
GetCurrentTime()21 	static inline __time64_t GetCurrentTime()
22 	{
23 		__time64_t currTime;
24 		_time64(&currTime);
25 		return currTime;
26 	}
27 
28 	/**
29 	 * Returns the current local time formatted as follows:
30 	 * "JJJJMMDD_HHmmSS", eg: "20091231_115959"
31 	 */
32 	static std::string GetCurrentTimeStr();
33 };
34 
35 #endif // TIME_UTIL_H
36