TrinityCore
Loading...
Searching...
No Matches
GameTime.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "GameTime.h"
19#include "Timer.h"
20#include "Timezone.h"
21#include "Util.h"
22#include "WowTime.h"
23
24namespace GameTime
25{
26 time_t const StartTime = time(nullptr);
27
28 time_t GameTime = time(nullptr);
30
31 SystemTimePoint GameTimeSystemPoint = SystemTimePoint ::min();
32 TimePoint GameTimeSteadyPoint = TimePoint::min();
33
36
37 time_t GetStartTime()
38 {
39 return StartTime;
40 }
41
42 time_t GetGameTime()
43 {
44 return GameTime;
45 }
46
48 {
49 return GameMSTime;
50 }
51
56
58 {
60 }
61
63 {
64 return uint32(GameTime - StartTime);
65 }
66
68 {
69 return &UtcWow;
70 }
71
73 {
74 return &Wow;
75 }
76
78 {
79 GameTime = time(nullptr);
81 GameTimeSystemPoint = std::chrono::system_clock::now();
82 GameTimeSteadyPoint = std::chrono::steady_clock::now();
85 }
86}
uint32_t uint32
Definition Define.h:133
std::chrono::system_clock::time_point SystemTimePoint
Definition Duration.h:37
std::chrono::steady_clock::time_point TimePoint
time_point shorthand typedefs
Definition Duration.h:36
uint32 getMSTime()
Definition Timer.h:33
void SetUtcTimeFromUnixTime(std::time_t unixTime)
Definition WowTime.cpp:86
WowTime UtcWow
Definition GameTime.cpp:34
WowTime const * GetWowTime()
Definition GameTime.cpp:72
WowTime const * GetUtcWowTime()
Definition GameTime.cpp:67
void UpdateGameTimers()
Definition GameTime.cpp:77
SystemTimePoint GetSystemTime()
Current chrono system_clock time point.
Definition GameTime.cpp:52
TimePoint Now()
Current chrono steady_clock time point.
Definition GameTime.cpp:57
WowTime Wow
Definition GameTime.cpp:35
time_t GetGameTime()
Definition GameTime.cpp:42
TimePoint GameTimeSteadyPoint
Definition GameTime.cpp:32
time_t GameTime
Definition GameTime.cpp:28
time_t GetStartTime()
Definition GameTime.cpp:37
uint32 GetUptime()
Uptime (in secs)
Definition GameTime.cpp:62
SystemTimePoint GameTimeSystemPoint
Definition GameTime.cpp:31
uint32 GetGameTimeMS()
Definition GameTime.cpp:47
time_t const StartTime
Definition GameTime.cpp:26
uint32 GameMSTime
Definition GameTime.cpp:29
Minutes GetSystemZoneOffsetAt(SystemTimePoint date)
Definition Timezone.cpp:133