diff src/core/date.cpp @ 63:3d2decf093bb

*: fix many clang warnings
author Paper <mrpapersonic@gmail.com>
date Sun, 01 Oct 2023 06:39:47 -0400
parents 75c804f713b2
children 6f7385bd334c
line wrap: on
line diff
--- a/src/core/date.cpp	Sun Oct 01 06:16:06 2023 -0400
+++ b/src/core/date.cpp	Sun Oct 01 06:39:47 2023 -0400
@@ -2,31 +2,13 @@
 #include "core/json.h"
 #include <QDate>
 #include <QDebug>
+#include <algorithm>
 #include <cstdint>
 #include <tuple>
 
 /* An implementation of AniList's "fuzzy date" */
 
-#define MIN(A, B) \
-	({ \
-		__typeof__(A) __a = (A); \
-		__typeof__(B) __b = (B); \
-		__a < __b ? __a : __b; \
-	})
-#define MAX(A, B) \
-	({ \
-		__typeof__(A) __a = (A); \
-		__typeof__(B) __b = (B); \
-		__a < __b ? __b : __a; \
-	})
-
-#define CLAMP(x, low, high) \
-	({ \
-		__typeof__(x) __x = (x); \
-		__typeof__(low) __low = (low); \
-		__typeof__(high) __high = (high); \
-		__x > __high ? __high : (__x < __low ? __low : __x); \
-	})
+#define CLAMP(x, low, high) (std::max(low, std::min(high, x)))
 
 Date::Date() {
 }
@@ -60,7 +42,7 @@
 }
 
 void Date::SetYear(unsigned int y) {
-	year.reset(new unsigned int(MAX(0U, y)));
+	year.reset(new unsigned int(y));
 }
 
 void Date::SetMonth(unsigned int m) {