Date.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* Date.cpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2026/01/16 18:06:10 by bchanot #+# #+# */
  9. /* Updated: 2026/01/16 19:34:38 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include <iomanip>
  13. #include "Date.hpp"
  14. bool operator<(const Date &a, const Date &b) {
  15. if (a.year != b.year)
  16. return a.year < b.year;
  17. if (a.month != b.month)
  18. return a.month < b.month;
  19. return a.day < b.day;
  20. }
  21. bool operator==(const Date &a, const Date &b) {
  22. return a.year == b.year && a.month == b.month && a.day == b.day;
  23. }
  24. bool operator!=(const Date &a, const Date &b) {
  25. return !(a == b);
  26. }
  27. std::ostream &operator<<(std::ostream &o, const Date &date) {
  28. o << date.year << "-" << std::setw(2) << std::setfill('0') << date.month << "-" << std::setw(2) << std::setfill('0') << date.day << std::setfill(' ');;
  29. return o;
  30. }