comparison include/core/date.h @ 202:71832ffe425a

animia: re-add kvm fd source this is all being merged from my wildly out-of-date laptop. SORRY! in other news, I edited the CI file to install the wayland client as well, so the linux CI build might finally get wayland stuff.
author Paper <paper@paper.us.eu.org>
date Tue, 02 Jan 2024 06:05:06 -0500
parents c4ca035c565d
children 862d0d8619f6
comparison
equal deleted inserted replaced
201:8f6f8dd2eb23 202:71832ffe425a
1 #ifndef __core__date_h 1 #ifndef __core__date_h
2 #define __core__date_h 2 #define __core__date_h
3 3
4 #include "json.h" 4 #include "json/json_fwd.hpp"
5 #include <QDate> 5
6 #include <cstdint> 6 #include <optional>
7
8 class QDate;
7 9
8 class Date { 10 class Date {
9 public: 11 public:
10 Date(); 12 Date();
11 Date(unsigned int y); 13 Date(unsigned int y);
12 Date(unsigned int y, unsigned int m, unsigned int d); 14 Date(unsigned int y, unsigned int m, unsigned int d);
13 Date(const QDate& date); 15 Date(const QDate& date);
16 Date(const nlohmann::json& json);
14 bool IsValid() const; 17 bool IsValid() const;
15 void SetYear(unsigned int y); 18 void SetYear(unsigned int y);
16 void SetMonth(unsigned int m); 19 void SetMonth(unsigned int m);
17 void SetDay(unsigned int d); 20 void SetDay(unsigned int d);
18 void VoidYear(); 21 void VoidYear();
19 void VoidMonth(); 22 void VoidMonth();
20 void VoidDay(); 23 void VoidDay();
21 unsigned int GetYear() const; 24 std::optional<unsigned int> GetYear() const;
22 unsigned int GetMonth() const; 25 std::optional<unsigned int> GetMonth() const;
23 unsigned int GetDay() const; 26 std::optional<unsigned int> GetDay() const;
24 QDate GetAsQDate() const; 27 QDate GetAsQDate() const;
25 nlohmann::json GetAsAniListJson() const; 28 nlohmann::json GetAsAniListJson() const;
26 bool operator<(const Date& other) const;
27 bool operator>(const Date& other) const;
28 bool operator<=(const Date& other) const;
29 bool operator>=(const Date& other) const;
30 29
31 private: 30 private:
32 /* note: it might be worth it to change these all to int, as 31 std::optional<unsigned int> year;
33 large bit precisions aren't exactly useful here... */ 32 std::optional<unsigned int> month;
34 std::shared_ptr<unsigned int> year; 33 std::optional<unsigned int> day;
35 std::shared_ptr<unsigned int> month;
36 std::shared_ptr<unsigned int> day;
37 }; 34 };
38 35
39 #endif // __core__date_h 36 #endif // __core__date_h