Mercurial > minori
annotate include/core/date.h @ 196:f0ff06a45c42
date: use std::optional for values
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Thu, 07 Dec 2023 16:28:11 -0500 |
parents | 9613d72b097e |
children | c4ca035c565d |
rev | line source |
---|---|
9 | 1 #ifndef __core__date_h |
2 #define __core__date_h | |
85 | 3 |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
4 #include "json/json_fwd.hpp" |
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
5 |
196
f0ff06a45c42
date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents:
187
diff
changeset
|
6 #include <optional> |
f0ff06a45c42
date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents:
187
diff
changeset
|
7 |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
8 class QDate; |
85 | 9 |
9 | 10 class Date { |
11 public: | |
12 Date(); | |
51 | 13 Date(unsigned int y); |
14 Date(unsigned int y, unsigned int m, unsigned int d); | |
15 Date(const QDate& date); | |
174
f88eda79c60a
anime/db: add some more json functionality, still doesn't compile :/
Paper <mrpapersonic@gmail.com>
parents:
85
diff
changeset
|
16 Date(const nlohmann::json& json); |
47
d8eb763e6661
information.cpp: add widgets to the list tab, and add an
Paper <mrpapersonic@gmail.com>
parents:
9
diff
changeset
|
17 bool IsValid() const; |
51 | 18 void SetYear(unsigned int y); |
19 void SetMonth(unsigned int m); | |
20 void SetDay(unsigned int d); | |
9 | 21 void VoidYear(); |
22 void VoidMonth(); | |
23 void VoidDay(); | |
51 | 24 unsigned int GetYear() const; |
25 unsigned int GetMonth() const; | |
26 unsigned int GetDay() const; | |
9 | 27 QDate GetAsQDate() const; |
28 nlohmann::json GetAsAniListJson() const; | |
29 bool operator<(const Date& other) const; | |
30 bool operator>(const Date& other) const; | |
31 bool operator<=(const Date& other) const; | |
32 bool operator>=(const Date& other) const; | |
33 | |
34 private: | |
196
f0ff06a45c42
date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents:
187
diff
changeset
|
35 std::optional<unsigned int> year; |
f0ff06a45c42
date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents:
187
diff
changeset
|
36 std::optional<unsigned int> month; |
f0ff06a45c42
date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents:
187
diff
changeset
|
37 std::optional<unsigned int> day; |
9 | 38 }; |
85 | 39 |
9 | 40 #endif // __core__date_h |