comparison include/core/date.h @ 51:75c804f713b2

window: add about window, *: use tr() when applicable (useful for i18n)
author Paper <mrpapersonic@gmail.com>
date Mon, 25 Sep 2023 20:29:26 -0400
parents d8eb763e6661
children c69230dc2b5d
comparison
equal deleted inserted replaced
50:10868c3fb2be 51:75c804f713b2
4 #include <QDate> 4 #include <QDate>
5 #include <cstdint> 5 #include <cstdint>
6 class Date { 6 class Date {
7 public: 7 public:
8 Date(); 8 Date();
9 Date(int32_t y); 9 Date(unsigned int y);
10 Date(int32_t y, int8_t m, int8_t d); 10 Date(unsigned int y, unsigned int m, unsigned int d);
11 Date(const QDate& date);
11 bool IsValid() const; 12 bool IsValid() const;
12 void SetYear(int32_t y); 13 void SetYear(unsigned int y);
13 void SetMonth(int8_t m); 14 void SetMonth(unsigned int m);
14 void SetDay(int8_t d); 15 void SetDay(unsigned int d);
15 void VoidYear(); 16 void VoidYear();
16 void VoidMonth(); 17 void VoidMonth();
17 void VoidDay(); 18 void VoidDay();
18 int32_t GetYear() const; 19 unsigned int GetYear() const;
19 int8_t GetMonth() const; 20 unsigned int GetMonth() const;
20 int8_t GetDay() const; 21 unsigned int GetDay() const;
21 QDate GetAsQDate() const; 22 QDate GetAsQDate() const;
22 nlohmann::json GetAsAniListJson() const; 23 nlohmann::json GetAsAniListJson() const;
23 bool operator<(const Date& other) const; 24 bool operator<(const Date& other) const;
24 bool operator>(const Date& other) const; 25 bool operator>(const Date& other) const;
25 bool operator<=(const Date& other) const; 26 bool operator<=(const Date& other) const;
26 bool operator>=(const Date& other) const; 27 bool operator>=(const Date& other) const;
27 28
28 private: 29 private:
29 std::shared_ptr<int32_t> year; 30 /* note: it might be worth it to change these all to int, as
30 std::shared_ptr<int8_t> month; 31 large bit precisions aren't exactly useful here... */
31 std::shared_ptr<int8_t> day; 32 std::shared_ptr<unsigned int> year;
33 std::shared_ptr<unsigned int> month;
34 std::shared_ptr<unsigned int> day;
32 }; 35 };
33 #endif // __core__date_h 36 #endif // __core__date_h