blob: a273d210d6a8f238d535b99971cfd7ebd62d402c (
plain)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITYCORE_WOWTIME_H
#define TRINITYCORE_WOWTIME_H
#include "Define.h"
#include "Duration.h"
#include "advstd.h"
#include <compare>
#include <ctime>
class ByteBuffer;
class WowTime
{
public:
uint32 GetPackedTime() const;
void SetPackedTime(uint32 packedTime);
std::time_t GetUnixTimeFromUtcTime() const;
void SetUtcTimeFromUnixTime(std::time_t unixTime);
int32 GetYear() const { return _year; }
void SetYear(int32 year);
int8 GetMonth() const { return _month; }
void SetMonth(int8 month);
int8 GetMonthDay() const { return _monthDay; }
void SetMonthDay(int8 monthDay);
int8 GetWeekDay() const { return _weekDay; }
void SetWeekDay(int8 weekDay);
int8 GetHour() const { return _hour; }
void SetHour(int8 hour);
int8 GetMinute() const { return _minute; }
void SetMinute(int8 minute);
int8 GetFlags() const { return _flags; }
void SetFlags(int8 flags);
int8 GetHolidayOffset() const { return _holidayOffset; }
void SetHolidayOffset(int8 holidayOffset) { _holidayOffset = holidayOffset; }
friend TC_GAME_API std::strong_ordering operator<=>(WowTime const& left, WowTime const& right);
friend TC_GAME_API bool operator==(WowTime const& left, WowTime const& right)
{
return advstd::is_eq(left <=> right);
}
bool IsInRange(WowTime const& from, WowTime const& to) const;
WowTime& operator+=(Seconds seconds);
WowTime operator+(Seconds seconds) const;
WowTime& operator-=(Seconds seconds);
WowTime operator-(Seconds seconds) const;
friend TC_GAME_API ByteBuffer& operator<<(ByteBuffer& data, WowTime const& wowTime);
friend TC_GAME_API ByteBuffer& operator>>(ByteBuffer& data, WowTime& wowTime);
private:
int32 _year = -1;
int8 _month = -1;
int8 _monthDay = -1;
int8 _weekDay = -1;
int8 _hour = -1;
int8 _minute = -1;
int8 _flags = -1;
int8 _holidayOffset = 0;
};
#endif // TRINITYCORE_WOWTIME_H
|