Mercurial > minori
diff 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 |
line wrap: on
line diff
--- a/include/core/date.h Sun Nov 19 19:13:28 2023 -0500 +++ b/include/core/date.h Tue Jan 02 06:05:06 2024 -0500 @@ -1,9 +1,11 @@ #ifndef __core__date_h #define __core__date_h -#include "json.h" -#include <QDate> -#include <cstdint> +#include "json/json_fwd.hpp" + +#include <optional> + +class QDate; class Date { public: @@ -11,6 +13,7 @@ Date(unsigned int y); Date(unsigned int y, unsigned int m, unsigned int d); Date(const QDate& date); + Date(const nlohmann::json& json); bool IsValid() const; void SetYear(unsigned int y); void SetMonth(unsigned int m); @@ -18,22 +21,16 @@ void VoidYear(); void VoidMonth(); void VoidDay(); - unsigned int GetYear() const; - unsigned int GetMonth() const; - unsigned int GetDay() const; + std::optional<unsigned int> GetYear() const; + std::optional<unsigned int> GetMonth() const; + std::optional<unsigned int> GetDay() const; QDate GetAsQDate() const; nlohmann::json GetAsAniListJson() const; - bool operator<(const Date& other) const; - bool operator>(const Date& other) const; - bool operator<=(const Date& other) const; - bool operator>=(const Date& other) const; private: - /* note: it might be worth it to change these all to int, as - large bit precisions aren't exactly useful here... */ - std::shared_ptr<unsigned int> year; - std::shared_ptr<unsigned int> month; - std::shared_ptr<unsigned int> day; + std::optional<unsigned int> year; + std::optional<unsigned int> month; + std::optional<unsigned int> day; }; #endif // __core__date_h
