Mercurial > minori
comparison 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 |
comparison
equal
deleted
inserted
replaced
46:d0adc4aedfc8 | 47:d8eb763e6661 |
---|---|
83 if (ptr != nullptr) | 83 if (ptr != nullptr) |
84 return *day; | 84 return *day; |
85 return -1; | 85 return -1; |
86 } | 86 } |
87 | 87 |
88 bool Date::IsValid() const { | |
89 return year.get() && month.get() && day.get(); | |
90 } | |
91 | |
88 bool Date::operator<(const Date& other) const { | 92 bool Date::operator<(const Date& other) const { |
93 int y = GetYear(), m = GetMonth(), d = GetDay(); | |
89 int o_y = other.GetYear(), o_m = other.GetMonth(), o_d = other.GetDay(); | 94 int o_y = other.GetYear(), o_m = other.GetMonth(), o_d = other.GetDay(); |
90 return std::tie(*year, *month, *day) < std::tie(o_y, o_m, o_d); | 95 return std::tie(y, m, d) < std::tie(o_y, o_m, o_d); |
91 } | 96 } |
92 | 97 |
93 bool Date::operator>(const Date& other) const { | 98 bool Date::operator>(const Date& other) const { |
94 return other < (*this); | 99 return other < (*this); |
95 } | 100 } |
101 bool Date::operator>=(const Date& other) const { | 106 bool Date::operator>=(const Date& other) const { |
102 return !((*this) < other); | 107 return !((*this) < other); |
103 } | 108 } |
104 | 109 |
105 QDate Date::GetAsQDate() const { | 110 QDate Date::GetAsQDate() const { |
106 /* QDates don't (yet) support "missing" values */ | 111 /* QDates don't support "missing" values, for good reason. */ |
107 if (year.get() && month.get() && day.get()) | 112 if (IsValid()) |
108 return QDate(*year, *month, *day); | 113 return QDate(*year, *month, *day); |
109 else | 114 else |
110 return QDate(); | 115 return QDate(); |
111 } | 116 } |
112 | 117 |