Mercurial > minori
annotate include/core/date.h @ 318:3b355fa948c7
config: use TOML instead of INI
unfortunately, INI is not enough, and causes some paths including
semicolons to break with our current storage of the library folders.
so, I decided to switch to TOML which does support real arrays...
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Wed, 12 Jun 2024 05:25:41 -0400 |
parents | b1f4d1867ab1 |
children | d928ec7b6a0d |
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> |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
7 #include <string> |
196
f0ff06a45c42
date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents:
187
diff
changeset
|
8 |
187
9613d72b097e
*: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents:
174
diff
changeset
|
9 class QDate; |
85 | 10 |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
11 /* TODO: refactor constructors, as they aren't meant |
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
12 * to be used in this way and may cause problems down |
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
13 * the line */ |
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
14 |
9 | 15 class Date { |
258 | 16 public: |
17 using Year = unsigned int; | |
18 using Day = unsigned char; | |
19 enum class Month { | |
20 Jan = 0, | |
21 Feb, | |
22 Mar, | |
23 Apr, | |
24 May, | |
25 Jun, | |
26 Jul, | |
27 Aug, | |
28 Sep, | |
29 Oct, | |
30 Nov, | |
31 Dec | |
32 }; | |
9 | 33 |
258 | 34 Date(); |
35 Date(Year y); | |
36 Date(Year y, Month m, Day d); | |
317
b1f4d1867ab1
services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents:
261
diff
changeset
|
37 Date(const std::string& str); |
258 | 38 Date(const QDate& date); |
39 Date(const nlohmann::json& json); | |
40 bool IsValid() const; | |
41 void SetYear(Year y); | |
42 void SetMonth(Month m); | |
43 void SetDay(Day d); | |
44 void VoidYear(); | |
45 void VoidMonth(); | |
46 void VoidDay(); | |
47 std::optional<Year> GetYear() const; | |
48 std::optional<Month> GetMonth() const; | |
49 std::optional<Day> GetDay() const; | |
50 QDate GetAsQDate() const; | |
51 nlohmann::json GetAsAniListJson() const; | |
52 | |
53 private: | |
54 std::optional<Year> year; | |
55 std::optional<Month> month; | |
56 std::optional<Day> day; | |
9 | 57 }; |
85 | 58 |
261
3ec7804abf17
include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents:
258
diff
changeset
|
59 #endif // MINORI_CORE_DATE_H_ |