AK: Define compound subtraction operator for UnixDateTime

This commit is contained in:
Timothy Flynn 2023-11-06 20:42:11 -05:00 committed by Andreas Kling
parent b3d5f9748a
commit 2437064820
Notes: sideshowbarker 2024-07-16 20:39:14 +09:00

View file

@ -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; }