diff src/core/date.cc @ 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 9b2b41f83a5e
children 9b10175be389
line wrap: on
line diff
--- a/src/core/date.cc	Tue Nov 28 13:53:54 2023 -0500
+++ b/src/core/date.cc	Wed Nov 29 13:53:56 2023 -0500
@@ -29,6 +29,15 @@
 	SetDay(date.day());
 }
 
+Date::Date(const nlohmann::json& json) {
+	if (json.contains("year") && json.at("year").is_number())
+		SetYear(json.at("year").get<unsigned int>());
+	if (json.contains("month") && json.at("month").is_number())
+		SetMonth(json.at("month").get<unsigned int>());
+	if (json.contains("day") && json.at("day").is_number())
+		SetDay(json.at("day").get<unsigned int>());
+}
+
 void Date::VoidYear() {
 	year.reset();
 }