Core/Calendar: Implement different timezone support for ingame calendar

Closes #8390
Closes #29427
This commit is contained in:
Shauren
2023-11-21 12:25:22 +01:00
parent 8c072b93af
commit b888b1b09f
47 changed files with 1182 additions and 456 deletions

View File

@@ -23,7 +23,6 @@
#include <utf8.h>
#include <sstream>
#include <cmath>
#include <ctime>
ByteBuffer::ByteBuffer(MessageBuffer&& buffer) : _rpos(0), _wpos(0), _bitpos(InitialBitPos), _curbitval(0), _storage(buffer.Move())
{
@@ -92,21 +91,6 @@ std::string ByteBuffer::ReadString(uint32 length, bool requireValidUtf8 /*= true
return value;
}
uint32 ByteBuffer::ReadPackedTime()
{
uint32 packedDate = read<uint32>();
tm lt = tm();
lt.tm_min = packedDate & 0x3F;
lt.tm_hour = (packedDate >> 6) & 0x1F;
//lt.tm_wday = (packedDate >> 11) & 7;
lt.tm_mday = ((packedDate >> 14) & 0x3F) + 1;
lt.tm_mon = (packedDate >> 20) & 0xF;
lt.tm_year = ((packedDate >> 24) & 0x1F) + 100;
return uint32(mktime(&lt));
}
void ByteBuffer::append(uint8 const* src, size_t cnt)
{
ASSERT(src, "Attempted to put a NULL-pointer in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", _wpos, size());
@@ -134,13 +118,6 @@ void ByteBuffer::append(uint8 const* src, size_t cnt)
_wpos = newSize;
}
void ByteBuffer::AppendPackedTime(time_t time)
{
tm lt;
localtime_r(&time, &lt);
append<uint32>((lt.tm_year - 100) << 24 | lt.tm_mon << 20 | (lt.tm_mday - 1) << 14 | lt.tm_wday << 11 | lt.tm_hour << 6 | lt.tm_min);
}
void ByteBuffer::put(size_t pos, uint8 const* src, size_t cnt)
{
ASSERT(pos + cnt <= size(), "Attempted to put value with size: " SZFMTD " in ByteBuffer (pos: " SZFMTD " size: " SZFMTD ")", cnt, pos, size());