Mercurial > minori
annotate include/core/date.h @ 298:dec4d3c9a909
scripts/win32/deploy_build: be more verbose with libs
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Mon, 13 May 2024 03:28:42 -0400 |
| parents | 3ec7804abf17 |
| children | b1f4d1867ab1 |
| rev | line source |
|---|---|
|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
1 #ifndef MINORI_CORE_DATE_H_ |
|
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
2 #define MINORI_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 { |
| 258 | 11 public: |
| 12 using Year = unsigned int; | |
| 13 using Day = unsigned char; | |
| 14 enum class Month { | |
| 15 Jan = 0, | |
| 16 Feb, | |
| 17 Mar, | |
| 18 Apr, | |
| 19 May, | |
| 20 Jun, | |
| 21 Jul, | |
| 22 Aug, | |
| 23 Sep, | |
| 24 Oct, | |
| 25 Nov, | |
| 26 Dec | |
| 27 }; | |
| 9 | 28 |
| 258 | 29 Date(); |
| 30 Date(Year y); | |
| 31 Date(Year y, Month m, Day d); | |
| 32 Date(const QDate& date); | |
| 33 Date(const nlohmann::json& json); | |
| 34 bool IsValid() const; | |
| 35 void SetYear(Year y); | |
| 36 void SetMonth(Month m); | |
| 37 void SetDay(Day d); | |
| 38 void VoidYear(); | |
| 39 void VoidMonth(); | |
| 40 void VoidDay(); | |
| 41 std::optional<Year> GetYear() const; | |
| 42 std::optional<Month> GetMonth() const; | |
| 43 std::optional<Day> GetDay() const; | |
| 44 QDate GetAsQDate() const; | |
| 45 nlohmann::json GetAsAniListJson() const; | |
| 46 | |
| 47 private: | |
| 48 std::optional<Year> year; | |
| 49 std::optional<Month> month; | |
| 50 std::optional<Day> day; | |
| 9 | 51 }; |
| 85 | 52 |
|
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
53 #endif // MINORI_CORE_DATE_H_ |
