summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2021-08-10 14:15:53 +0200
committerMax Kellermann <max@musicpd.org>2021-08-10 15:13:16 +0200
commit1976003e91170b53d3d22d506d862f46db162df5 (patch)
tree40efcece1493813d2829bf965babb7e4de854baf
parent488afc47d41c8d6ea8c0d7215d88d176402d04a6 (diff)
time/FileTime: allow negative times
-rw-r--r--src/time/FileTime.hxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/time/FileTime.hxx b/src/time/FileTime.hxx
index 67fd5770b..a134433e3 100644
--- a/src/time/FileTime.hxx
+++ b/src/time/FileTime.hxx
@@ -47,10 +47,16 @@ ToUint64(FILETIME ft) noexcept
return ConstructUint64(ft.dwLowDateTime, ft.dwHighDateTime);
}
+constexpr int_least64_t
+ToInt64(FILETIME ft) noexcept
+{
+ return ToUint64(ft);
+}
+
constexpr time_t
FileTimeToTimeT(FILETIME ft) noexcept
{
- return (ToUint64(ft) - 116444736000000000) / 10000000;
+ return (ToInt64(ft) - 116444736000000000) / 10000000;
}
inline std::chrono::system_clock::time_point
@@ -63,7 +69,7 @@ FileTimeToChrono(FILETIME ft) noexcept
constexpr std::chrono::seconds
DeltaFileTimeS(FILETIME a, FILETIME b) noexcept
{
- return std::chrono::seconds((ToUint64(a) - ToUint64(b)) / 10000000);
+ return std::chrono::seconds((ToInt64(a) - ToInt64(b)) / 10000000);
}
#endif