Skip to content

Commit 53dcf8b

Browse files
jsaylor525BillyONeal
authored andcommitted
Added comparison overrides to utility::datetime (microsoft#1276)
I was trying to compare timestamps and noticed that the code doesn't support this so std::max and std::min don't work with datetime timestamps. I've added less/greater/less-or-equal/greater-or-equal operators.
1 parent e7c6b08 commit 53dcf8b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Release/include/cpprest/asyncrt_utils.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,14 @@ class datetime
628628
bool operator==(datetime dt) const { return m_interval == dt.m_interval; }
629629

630630
bool operator!=(const datetime& dt) const { return !(*this == dt); }
631+
632+
bool operator>(const datetime& dt) const { return this->m_interval > dt.m_interval; }
633+
634+
bool operator<(const datetime& dt) const { return this->m_interval < dt.m_interval; }
635+
636+
bool operator>=(const datetime& dt) const { return this->m_interval >= dt.m_interval; }
637+
638+
bool operator<=(const datetime& dt) const { return this->m_interval <= dt.m_interval; }
631639

632640
static interval_type from_milliseconds(unsigned int milliseconds) { return milliseconds * _msTicks; }
633641

0 commit comments

Comments
 (0)