aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2012-09-13 16:38:18 +0200
committerShauren <shauren.trinity@gmail.com>2012-09-13 16:38:18 +0200
commitf03e650474463ad7454294e0fb5d6f169719ecbd (patch)
tree3e983db618358fc16fb140e018c20a617d8edb47 /src/server/shared
parent13e140cfac6f8de5e79d804e197903d47f1b017d (diff)
Core/Calendar: Fixed breaking calendar event UI after relogging
Diffstat (limited to 'src/server/shared')
-rwxr-xr-xsrc/server/shared/Packets/ByteBuffer.h28
-rwxr-xr-xsrc/server/shared/Utilities/Util.h6
2 files changed, 28 insertions, 6 deletions
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index 760fcfd48d9..1fa3148504a 100755
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -359,6 +359,28 @@ class ByteBuffer
}
}
+ uint32 ReadPackedTime()
+ {
+ uint32 packedDate = read<uint32>();
+ tm lt;
+ memset(&lt, 0, sizeof(lt));
+
+ 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 mktime(&lt) + timezone;
+ }
+
+ ByteBuffer& ReadPackedTime(uint32& time)
+ {
+ time = ReadPackedTime();
+ return *this;
+ }
+
const uint8 *contents() const { return &_storage[0]; }
size_t size() const { return _storage.size(); }
@@ -438,6 +460,12 @@ class ByteBuffer
append(packGUID, size);
}
+ void AppendPackedTime(time_t time)
+ {
+ tm* lt = localtime(&time);
+ 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 put(size_t pos, const uint8 *src, size_t cnt)
{
if (pos + cnt > size())
diff --git a/src/server/shared/Utilities/Util.h b/src/server/shared/Utilities/Util.h
index 835473045d4..37782c31d8b 100755
--- a/src/server/shared/Utilities/Util.h
+++ b/src/server/shared/Utilities/Util.h
@@ -48,12 +48,6 @@ std::string secsToTimeString(uint64 timeInSecs, bool shortText = false, bool hou
uint32 TimeStringToSecs(const std::string& timestring);
std::string TimeToTimestampStr(time_t t);
-inline uint32 secsToTimeBitFields(time_t secs)
-{
- tm* lt = localtime(&secs);
- return 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);
-}
-
/* Return a random number in the range min..max; (max-min) must be smaller than 32768. */
int32 irand(int32 min, int32 max);