comparison include/core/date.h @ 174:f88eda79c60a

anime/db: add some more json functionality, still doesn't compile :/
author Paper <mrpapersonic@gmail.com>
date Wed, 29 Nov 2023 13:53:56 -0500
parents c69230dc2b5d
children 9613d72b097e
comparison
equal deleted inserted replaced
173:de0a8d2f28b3 174:f88eda79c60a
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 "core/json.h"
5 #include <QDate> 5 #include <QDate>
6 #include <cstdint> 6 #include <cstdint>
7 7
8 class Date { 8 class Date {
9 public: 9 public:
10 Date(); 10 Date();
11 Date(unsigned int y); 11 Date(unsigned int y);
12 Date(unsigned int y, unsigned int m, unsigned int d); 12 Date(unsigned int y, unsigned int m, unsigned int d);
13 Date(const QDate& date); 13 Date(const QDate& date);
14 Date(const nlohmann::json& json);
14 bool IsValid() const; 15 bool IsValid() const;
15 void SetYear(unsigned int y); 16 void SetYear(unsigned int y);
16 void SetMonth(unsigned int m); 17 void SetMonth(unsigned int m);
17 void SetDay(unsigned int d); 18 void SetDay(unsigned int d);
18 void VoidYear(); 19 void VoidYear();
27 bool operator>(const Date& other) const; 28 bool operator>(const Date& other) const;
28 bool operator<=(const Date& other) const; 29 bool operator<=(const Date& other) const;
29 bool operator>=(const Date& other) const; 30 bool operator>=(const Date& other) const;
30 31
31 private: 32 private:
32 /* note: it might be worth it to change these all to int, as 33 /* this implementation sucks and we should really use a struct instead */
33 large bit precisions aren't exactly useful here... */
34 std::shared_ptr<unsigned int> year; 34 std::shared_ptr<unsigned int> year;
35 std::shared_ptr<unsigned int> month; 35 std::shared_ptr<unsigned int> month;
36 std::shared_ptr<unsigned int> day; 36 std::shared_ptr<unsigned int> day;
37 }; 37 };
38 38