diff --git a/src/Helpers/TimeAndDate.cpp b/src/Helpers/TimeAndDate.cpp index 1d93ac5eb8881b5b8014d99e89bc1628c8c543e7..0c5a1899fc5b1b528f2f70c0a7ab47caac4994d4 100644 --- a/src/Helpers/TimeAndDate.cpp +++ b/src/Helpers/TimeAndDate.cpp @@ -1,183 +1,221 @@ #include "Helpers/TimeHelper.hpp" bool TimeAndDate::operator<(const TimeAndDate &Date) { + //@note clang tidy complaints when using else after return so that's why there are these + // numerous if checks. Sorry for the ugly code... + // compare years if (this->year < Date.year) { return true; - } else if (this->year > Date.year) { + } + if (this->year > Date.year) { return false; } // compare months if (this->month < Date.month) { return true; - } else if (this->month > Date.month) { + } + if (this->month > Date.month) { return false; } // compare days if (this->day < Date.day) { return true; - } else if (this->day > Date.day) { + } + if (this->day > Date.day) { return false; } // compare hours if (this->hour < Date.hour) { return true; - } else if (this->hour > Date.hour) { + } + if (this->hour > Date.hour) { return false; } // compare minutes if (this->minute < Date.minute) { return true; - } else if (this->minute > Date.minute) { + } + if (this->minute > Date.minute) { return false; } // compare seconds if (this->second < Date.second) { return true; - } else { - return false; } + + return false; + } bool TimeAndDate::operator>(const TimeAndDate &Date) { + //@note clang tidy complaints when using else after return so that's why there are these + // numerous if checks. Sorry for the ugly code... + // compare years if (this->year > Date.year) { return true; - } else if (this->year < Date.year) { + } + if (this->year < Date.year) { return false; } // compare months if (this->month > Date.month) { return true; - } else if (this->month < Date.month) { + } + if (this->month < Date.month) { return false; } // compare days if (this->day > Date.day) { return true; - } else if (this->day < Date.day) { + } + if (this->day < Date.day) { return false; } // compare hours if (this->hour > Date.hour) { return true; - } else if (this->hour < Date.hour) { + } + if (this->hour < Date.hour) { return false; } // compare minutes if (this->minute > Date.minute) { return true; - } else if (this->minute < Date.minute) { + } + if (this->minute < Date.minute) { return false; } // compare seconds if (this->second > Date.second) { return true; - } else { - return false; } + + return false; + } bool TimeAndDate::operator<=(const TimeAndDate &Date) { + //@note clang tidy complaints when using else after return so that's why there are these + // numerous if checks. Sorry for the ugly code... + // compare years if (this->year < Date.year) { return true; - } else if (this->year > Date.year) { + } + if (this->year > Date.year) { return false; } // compare months if (this->month < Date.month) { return true; - } else if (this->month > Date.month) { + } + if (this->month > Date.month) { return false; } // compare days if (this->day < Date.day) { return true; - } else if (this->day > Date.day) { + } + if (this->day > Date.day) { return false; } // compare hours if (this->hour < Date.hour) { return true; - } else if (this->hour > Date.hour) { + } + if (this->hour > Date.hour) { return false; } // compare minutes if (this->minute < Date.minute) { return true; - } else if (this->minute > Date.minute) { + } + if (this->minute > Date.minute) { return false; } // compare seconds if (this->second < Date.second) { return true; - } else if (this->second > Date.second) { + } + if (this->second > Date.second) { return false; - } else { - return true; } + + return true; + } bool TimeAndDate::operator>=(const TimeAndDate &Date) { + //@note clang tidy complaints when using else after return so that's why there are these + // numerous if checks. Sorry for the ugly code... + // compare years if (this->year > Date.year) { return true; - } else if (this->year < Date.year) { + } + if (this->year < Date.year) { return false; } // compare months if (this->month > Date.month) { return true; - } else if (this->month < Date.month) { + } + if (this->month < Date.month) { return false; } // compare days if (this->day > Date.day) { return true; - } else if (this->day < Date.day) { + } + if (this->day < Date.day) { return false; } // compare hours if (this->hour > Date.hour) { return true; - } else if (this->hour < Date.hour) { + } + if (this->hour < Date.hour) { return false; } // compare minutes if (this->minute > Date.minute) { return true; - } else if (this->minute < Date.minute) { + } + if (this->minute < Date.minute) { return false; } // compare seconds if (this->second > Date.second) { return true; - } else if (this->second < Date.second) { + } + if (this->second < Date.second) { return false; - } else { - return true; } + + return true; + } bool TimeAndDate::operator==(const TimeAndDate &Date) { @@ -209,7 +247,8 @@ bool TimeAndDate::operator==(const TimeAndDate &Date) { // compare seconds if (this->second != Date.second) { return false; - } else { - return true; } -} \ No newline at end of file + + return true; + +}