EvEmu  0.8.4
11 September 2021
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
utils_time.h
Go to the documentation of this file.
1 /*
2  ------------------------------------------------------------------------------------
3  LICENSE:
4  ------------------------------------------------------------------------------------
5  This file is part of EVEmu: EVE Online Server Emulator
6  Copyright 2006 - 2021 The EVEmu Team
7  For the latest information visit https://evemu.dev
8  ------------------------------------------------------------------------------------
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License along with
19  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
20  Place - Suite 330, Boston, MA 02111-1307, USA, or go to
21  http://www.gnu.org/copyleft/lesser.txt.
22  ------------------------------------------------------------------------------------
23  Author: Zhur
24  Updates: Allan
25 */
26 
27 #ifndef __UTILS_TIME_H__INCL__
28 #define __UTILS_TIME_H__INCL__
29 
30 /*
31 SEC = 10000000L
32 MIN = (SEC * 60L)
33 HOUR = (MIN * 60L)
34 DAY = (HOUR * 24L)
35 MONTH = (30 * DAY)
36 YEAR = (12 * MONTH)
37 */
38 namespace EvE {
39  namespace Time {
40  enum:int64_t {
41  mSecond = 1000L, //1000
42  Second = 10000000L, //10000000
43  Minute = (Second * 60L),
44  Hour = (Minute * 60L),
45  Day = (Hour * 24L),
46  Week = (Day * 7L),
47  Month = (Day * 30L),
48  Year = (Day * 365L)
49  };
50  }
51 
52  struct TimeParts {
55  uint8 wd; // day of week
56  uint8 wn; // week of year
61  uint16 dy; // day of year
63  };
64 
65 }
66 
67 extern const int64 Win32Time_Second;
68 extern const int64 Win32Time_Minute;
69 extern const int64 Win32Time_Hour;
70 extern const int64 Win32Time_Day;
71 extern const int64 Win32Time_Month;
72 extern const int64 Win32Time_Year;
73 extern int64 UnixTimeToWin32Time( time_t sec, uint32 nsec );
74 extern int64 Win32TimeNow();
75 extern void Win32TimeToUnixTime( int64 win32t, time_t &unix_time, uint32 &nsec );
76 extern std::string Win32TimeToString(int64 win32t);
77 
78 // returns delta between time and now, in hours
80 // this returns 100 nanosecond resolution in filetime format
81 double GetFileTimeNow(); // replacement for Win32TimeNow()
82 // this returns milliseconds
84 // this returns milliseconds in microsecond resolution
85 double GetTimeMSeconds();
86 // this returns microseconds in nanosecond resolution
87 double GetTimeUSeconds();
88 
89 // return elapsed time formatted in units
90 std::string GetUTimeTillNow(double fromTime);
91 // return elapsed time formatted in units
92 std::string GetMTimeTillNow(double fromTime);
93 
94 // Get current date/time, format is YYYY-MM-DD.HH:mm:ss
95 const std::string currentDateTime();
96 
97 // break down given filetime into year, month, day, hour, min, sec, ms
98 EvE::TimeParts GetTimeParts(int64 filetime=0); // also gives day of week, day of year, and week of year
99 
100 // Get linux filetime from dataTime format YYYY-MM-DDTHH:mm:ssZ (where "T" is a separator and "Z" denotes 'zulo')
101 //std::time_t getEpochTime(const std::wstring& dateTime);
102 
103 #endif /* !__UTILS_TIME_H__INCL__ */
int64 UnixTimeToWin32Time(time_t sec, uint32 nsec)
Definition: utils_time.cpp:45
unsigned __int8 uint8
Definition: eve-compat.h:46
const int64 Win32Time_Minute
Definition: utils_time.cpp:39
double GetTimeUSeconds()
Definition: utils_time.cpp:116
EvE::TimeParts GetTimeParts(int64 filetime=0)
Definition: utils_time.cpp:157
int32 GetElapsedHours(int64 time)
Definition: utils_time.cpp:75
int64 Win32TimeNow()
Definition: utils_time.cpp:70
std::string Win32TimeToString(int64 win32t)
Definition: utils_time.cpp:59
const int64 Win32Time_Month
Definition: utils_time.cpp:42
signed __int32 int32
Definition: eve-compat.h:49
int64 GetSteadyTime()
Definition: utils_time.cpp:95
double GetTimeMSeconds()
Definition: utils_time.cpp:104
Definition: Trig.h:15
double GetFileTimeNow()
Definition: utils_time.cpp:84
unsigned __int32 uint32
Definition: eve-compat.h:50
signed __int64 int64
Definition: eve-compat.h:51
const int64 Win32Time_Hour
Definition: utils_time.cpp:40
const int64 Win32Time_Year
Definition: utils_time.cpp:43
const int64 Win32Time_Day
Definition: utils_time.cpp:41
const std::string currentDateTime()
Definition: utils_time.cpp:125
std::string GetMTimeTillNow(double fromTime)
Definition: utils_time.cpp:148
std::string GetUTimeTillNow(double fromTime)
Definition: utils_time.cpp:137
unsigned __int16 uint16
Definition: eve-compat.h:48
void Win32TimeToUnixTime(int64 win32t, time_t &unix_time, uint32 &nsec)
Definition: utils_time.cpp:52
const int64 Win32Time_Second
Definition: utils_time.cpp:38