diff options
author | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-08-14 22:50:43 +0800 |
commit | 15740faf9fe9fe4be08965098bbf2947e096aeeb (patch) | |
tree | a730ec236656cc8cab5b13f088adfaed6bb218fb /Runtime/Utilities/DateTime.cpp |
Diffstat (limited to 'Runtime/Utilities/DateTime.cpp')
-rw-r--r-- | Runtime/Utilities/DateTime.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
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); +} |