From 15740faf9fe9fe4be08965098bbf2947e096aeeb Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Aug 2019 22:50:43 +0800 Subject: +Unity Runtime code --- Runtime/Utilities/DateTime.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Runtime/Utilities/DateTime.cpp (limited to 'Runtime/Utilities/DateTime.cpp') diff --git a/Runtime/Utilities/DateTime.cpp b/Runtime/Utilities/DateTime.cpp new file mode 100644 index 0000000..b95e06c --- /dev/null +++ b/Runtime/Utilities/DateTime.cpp @@ -0,0 +1,45 @@ +#include "UnityPrefix.h" +#include "DateTime.h" +#include "Runtime/Serialize/SwapEndianBytes.h" + + +DateTime::DateTime () +{ + highSeconds = 0; + lowSeconds = 0; + fraction = 0; +} + +bool operator < (const DateTime& d0, const DateTime& d1) +{ + if (d0.highSeconds < d1.highSeconds) + return true; + else if (d0.highSeconds > d1.highSeconds) + return false; + + if (d0.lowSeconds < d1.lowSeconds) + return true; + else if (d0.lowSeconds > d1.lowSeconds) + return false; + + return d0.fraction < d1.fraction; +} + +bool operator == (const DateTime& d0, const DateTime& d1) +{ + if (d0.highSeconds != d1.highSeconds) + return false; + + if (d0.lowSeconds != d1.lowSeconds) + return false; + + return d0.fraction == d1.fraction; +} + + +void ByteSwapDateTime (DateTime& dateTime) +{ + SwapEndianBytes(dateTime.highSeconds); + SwapEndianBytes(dateTime.fraction); + SwapEndianBytes(dateTime.lowSeconds); +} -- cgit v1.1-26-g67d0