diff src/core/date.cpp @ 47:d8eb763e6661

information.cpp: add widgets to the list tab, and add an "optional date" widget like taiga has so users can specify whether to set the date or not
author Paper <mrpapersonic@gmail.com>
date Mon, 25 Sep 2023 00:43:38 -0400
parents 2743011a6042
children 75c804f713b2
line wrap: on
line diff
--- a/src/core/date.cpp	Sat Sep 23 01:02:15 2023 -0400
+++ b/src/core/date.cpp	Mon Sep 25 00:43:38 2023 -0400
@@ -85,9 +85,14 @@
 	return -1;
 }
 
+bool Date::IsValid() const {
+	return year.get() && month.get() && day.get();
+}
+
 bool Date::operator<(const Date& other) const {
+	int y = GetYear(), m = GetMonth(), d = GetDay();
 	int o_y = other.GetYear(), o_m = other.GetMonth(), o_d = other.GetDay();
-	return std::tie(*year, *month, *day) < std::tie(o_y, o_m, o_d);
+	return std::tie(y, m, d) < std::tie(o_y, o_m, o_d);
 }
 
 bool Date::operator>(const Date& other) const {
@@ -103,8 +108,8 @@
 }
 
 QDate Date::GetAsQDate() const {
-	/* QDates don't (yet) support "missing" values */
-	if (year.get() && month.get() && day.get())
+	/* QDates don't support "missing" values, for good reason. */
+	if (IsValid())
 		return QDate(*year, *month, *day);
 	else
 		return QDate();