diff src/core/date.cc @ 369:47c9f8502269

*: clang-format all the things I've edited the formatting a bit. Now pointer asterisks (and reference ampersands) are on the variable instead of the type, as well as having newlines for function braces (but nothing else)
author Paper <paper@tflc.us>
date Fri, 25 Jul 2025 10:16:02 -0400
parents d928ec7b6a0d
children
line wrap: on
line diff
--- a/src/core/date.cc	Fri Jul 25 10:05:23 2025 -0400
+++ b/src/core/date.cc	Fri Jul 25 10:16:02 2025 -0400
@@ -1,6 +1,6 @@
 #include "core/date.h"
+#include "core/json.h"
 #include "core/time.h"
-#include "core/json.h"
 
 #include <QDate>
 #include <QDebug>
@@ -10,20 +10,24 @@
 
 /* An implementation of AniList's "fuzzy date" */
 
-Date::Date() {
+Date::Date()
+{
 }
 
-Date::Date(Date::Year y) {
+Date::Date(Date::Year y)
+{
 	SetYear(y);
 }
 
-Date::Date(Date::Year y, Date::Month m, Date::Day d) {
+Date::Date(Date::Year y, Date::Month m, Date::Day d)
+{
 	SetYear(y);
 	SetMonth(m);
 	SetDay(d);
 }
 
-Date::Date(const std::string& str) {
+Date::Date(const std::string &str)
+{
 	unsigned int y, m, d;
 
 	/* I don't like this that much, but it works... */
@@ -39,7 +43,8 @@
 		SetDay(d);
 }
 
-Date::Date(const QDate& date) {
+Date::Date(const QDate &date)
+{
 	SetYear(date.year());
 	auto m = date.month();
 	m = std::clamp(m, static_cast<decltype(m)>(Date::Month::Jan), static_cast<decltype(m)>(Date::Month::Dec));
@@ -47,7 +52,8 @@
 	SetDay(date.day());
 }
 
-Date::Date(const nlohmann::json& json) {
+Date::Date(const nlohmann::json &json)
+{
 	/* NOTE: this constructor is made for use with
 	 * AniList FuzzyDate-style JSON. In the future, some other
 	 * methods may be parsed and whatnot if necessary. */
@@ -65,51 +71,63 @@
 		SetDay(json.at("/day"_json_pointer).get<unsigned char>());
 }
 
-Date::Date(Time::Timestamp timestamp) {
+Date::Date(Time::Timestamp timestamp)
+{
 	Date(QDateTime::fromSecsSinceEpoch(timestamp).date());
 }
 
-void Date::VoidYear() {
+void Date::VoidYear()
+{
 	year.reset();
 }
 
-void Date::VoidMonth() {
+void Date::VoidMonth()
+{
 	month.reset();
 }
 
-void Date::VoidDay() {
+void Date::VoidDay()
+{
 	day.reset();
 }
 
-void Date::SetYear(Date::Year y) {
+void Date::SetYear(Date::Year y)
+{
 	year.emplace(y);
 }
 
-void Date::SetMonth(Date::Month m) {
+void Date::SetMonth(Date::Month m)
+{
 	month.emplace(m);
 }
 
-void Date::SetDay(Date::Day d) {
+void Date::SetDay(Date::Day d)
+{
 	day.emplace(std::clamp(d, static_cast<Date::Day>(1U), static_cast<Date::Day>(31U)));
 }
 
-std::optional<Date::Year> Date::GetYear() const {
+std::optional<Date::Year> Date::GetYear() const
+{
 	return year;
 }
 
-std::optional<Date::Month> Date::GetMonth() const {
+std::optional<Date::Month> Date::GetMonth() const
+{
 	return month;
 }
 
-std::optional<Date::Day> Date::GetDay() const {
+std::optional<Date::Day> Date::GetDay() const
+{
 	return day;
 }
 
-bool Date::IsValid() const {
+bool Date::IsValid() const
+{
 	return year.has_value() && month.has_value() && day.has_value();
 }
 
-QDate Date::GetAsQDate() const {
+QDate Date::GetAsQDate() const
+{
 	/* QDate doesn't support "missing" values (for good reason),
 	 * so we do our best and return what we can.
 	 */
@@ -117,7 +135,8 @@
 	return QDate(year.value_or(2000), static_cast<unsigned int>(month.value_or(Date::Month::Jan)), day.value_or(1));
 }
 
-nlohmann::json Date::GetAsAniListJson() const {
+nlohmann::json Date::GetAsAniListJson() const
+{
 	nlohmann::json json = {
 	    {"year",  nullptr},
         {"month", nullptr},