Adding support for partial dates (only year or month), fixes #477

This commit is contained in:
emeric
2025-01-19 23:50:39 +01:00
parent c73ff7dc03
commit 33759def78
27 changed files with 594 additions and 170 deletions
+6 -10
View File
@@ -23,20 +23,16 @@
namespace lms::api::subsonic
{
Response::Node createItemDateNode(const Wt::WDate& date, std::optional<int> year)
Response::Node createItemDateNode(const core::PartialDateTime& date)
{
Response::Node itemDateNode;
if (date.isValid())
{
itemDateNode.setAttribute("year", date.year());
itemDateNode.setAttribute("month", date.month());
itemDateNode.setAttribute("day", date.day());
}
else if (year)
{
if (auto year{ date.getYear() })
itemDateNode.setAttribute("year", *year);
}
if (auto month{ date.getMonth() })
itemDateNode.setAttribute("month", *month);
if (auto day{ date.getDay() })
itemDateNode.setAttribute("day", *day);
return itemDateNode;
}