mirror of
https://github.com/Rogiel/PacketBuffer
synced 2025-12-06 00:13:04 +00:00
Fix a bug that caused serialized dates to not be cross platform
This commit is contained in:
@@ -71,14 +71,17 @@ namespace PacketBuffer {
|
|||||||
public:
|
public:
|
||||||
template<typename Packer>
|
template<typename Packer>
|
||||||
static inline void pack(Packer& packer, const std::chrono::time_point<Clock, Duration>& point) {
|
static inline void pack(Packer& packer, const std::chrono::time_point<Clock, Duration>& point) {
|
||||||
packer(point.time_since_epoch());
|
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||||
|
point.time_since_epoch());
|
||||||
|
packer(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename Unpacker>
|
template<typename Unpacker>
|
||||||
static inline void unpack(Unpacker& unpacker, std::chrono::time_point<Clock, Duration>& point) {
|
static inline void unpack(Unpacker& unpacker, std::chrono::time_point<Clock, Duration>& point) {
|
||||||
Duration d;
|
std::chrono::milliseconds duration;
|
||||||
unpacker(d);
|
unpacker(duration);
|
||||||
point = std::chrono::time_point<Clock, Duration>(d);
|
point = std::chrono::time_point<Clock, Duration>(
|
||||||
|
std::chrono::duration_cast<Duration>(duration));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user