From 24370648200522e9034462fc10a7d40980be32e4 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Mon, 6 Nov 2023 20:42:11 -0500 Subject: [PATCH] AK: Define compound subtraction operator for UnixDateTime --- AK/Time.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/AK/Time.h b/AK/Time.h index 8f6e116da11..1813822b3ae 100644 --- a/AK/Time.h +++ b/AK/Time.h @@ -439,7 +439,14 @@ public: this->m_offset = this->m_offset + other; return *this; } + constexpr UnixDateTime operator-(Duration const& other) const { return UnixDateTime { m_offset - other }; } + constexpr UnixDateTime& operator-=(Duration const& other) + { + m_offset = m_offset - other; + return *this; + } + // Subtracting two UNIX times yields their time difference. constexpr Duration operator-(UnixDateTime const& other) const { return m_offset - other.m_offset; }