view include/core/date.h @ 266:1a6a5d3a94cd

dep/animone: make bsd.cc and x11.cc actually work apparently I broke these, and even now the x11 code *still* doesn't want to work correctly (at least on FreeBSD). half of the PID response codes are just 0 or the PID for the X server itself... wtf? maybe dwm just doesn't support the XRes extension, or I'm just stupid. i don't know.
author Paper <paper@paper.us.eu.org>
date Thu, 11 Apr 2024 22:05:41 -0400
parents 3ec7804abf17
children b1f4d1867ab1
line wrap: on
line source

#ifndef MINORI_CORE_DATE_H_
#define MINORI_CORE_DATE_H_

#include "json/json_fwd.hpp"

#include <optional>

class QDate;

class Date {
public:
	using Year = unsigned int;
	using Day = unsigned char;
	enum class Month {
		Jan = 0,
		Feb,
		Mar,
		Apr,
		May,
		Jun,
		Jul,
		Aug,
		Sep,
		Oct,
		Nov,
		Dec
	};

	Date();
	Date(Year y);
	Date(Year y, Month m, Day d);
	Date(const QDate& date);
	Date(const nlohmann::json& json);
	bool IsValid() const;
	void SetYear(Year y);
	void SetMonth(Month m);
	void SetDay(Day d);
	void VoidYear();
	void VoidMonth();
	void VoidDay();
	std::optional<Year> GetYear() const;
	std::optional<Month> GetMonth() const;
	std::optional<Day> GetDay() const;
	QDate GetAsQDate() const;
	nlohmann::json GetAsAniListJson() const;

private:
	std::optional<Year> year;
	std::optional<Month> month;
	std::optional<Day> day;
};

#endif // MINORI_CORE_DATE_H_