annotate include/core/date.h @ 327:b5d6c27c308f

anime: refactor Anime::SeriesSeason to Season class ToLocalString has also been altered to take in both season and year because lots of locales actually treat formatting seasons differently! most notably is Russian which adds a suffix at the end to notate seasons(??)
author Paper <paper@paper.us.eu.org>
date Thu, 13 Jun 2024 01:49:18 -0400
parents d928ec7b6a0d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
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
319
d928ec7b6a0d services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
6 #include "core/time.h"
d928ec7b6a0d services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
7
196
f0ff06a45c42 date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
8 #include <optional>
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 261
diff changeset
9 #include <string>
196
f0ff06a45c42 date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents: 187
diff changeset
10
187
9613d72b097e *: multiple performance improvements
Paper <mrpapersonic@gmail.com>
parents: 174
diff changeset
11 class QDate;
85
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
12
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 261
diff changeset
13 /* TODO: refactor constructors, as they aren't meant
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 261
diff changeset
14 * 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
15 * the line */
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 261
diff changeset
16
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 class Date {
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
18 public:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
19 using Year = unsigned int;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
20 using Day = unsigned char;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
21 enum class Month {
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
22 Jan = 0,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
23 Feb,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
24 Mar,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
25 Apr,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
26 May,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
27 Jun,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
28 Jul,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
29 Aug,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
30 Sep,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
31 Oct,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
32 Nov,
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
33 Dec
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
34 };
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
36 Date();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
37 Date(Year y);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
38 Date(Year y, Month m, Day d);
317
b1f4d1867ab1 services: VERY initial Kitsu support
Paper <paper@paper.us.eu.org>
parents: 261
diff changeset
39 Date(const std::string& str);
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
40 Date(const QDate& date);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
41 Date(const nlohmann::json& json);
319
d928ec7b6a0d services/kitsu: implement GetAnimeList()
Paper <paper@paper.us.eu.org>
parents: 317
diff changeset
42 Date(Time::Timestamp timestamp);
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
43
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
44 bool IsValid() const;
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
45
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
46 void SetYear(Year y);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
47 void SetMonth(Month m);
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
48 void SetDay(Day d);
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
49
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
50 void VoidYear();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
51 void VoidMonth();
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
52 void VoidDay();
327
b5d6c27c308f anime: refactor Anime::SeriesSeason to Season class
Paper <paper@paper.us.eu.org>
parents: 319
diff changeset
53
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
54 std::optional<Year> GetYear() const;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
55 std::optional<Month> GetMonth() const;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
56 std::optional<Day> GetDay() const;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
57 QDate GetAsQDate() const;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
58 nlohmann::json GetAsAniListJson() const;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
59
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
60 private:
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
61 std::optional<Year> year;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
62 std::optional<Month> month;
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 197
diff changeset
63 std::optional<Day> day;
9
5c0397762b53 INCOMPLETE: megacommit :)
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64 };
85
c69230dc2b5d *: cleanup includes
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
65
261
3ec7804abf17 include: make header guards more sane
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
66 #endif // MINORI_CORE_DATE_H_