diff --git a/src/book.cpp b/src/book.cpp index 6d41a87e..02489ac0 100644 --- a/src/book.cpp +++ b/src/book.cpp @@ -131,6 +131,14 @@ void Book::updateFromXml(const pugi::xml_node& node, const std::string& baseDir) #undef ATTR +static std::string fromOpdsDate(const std::string& date) +{ + //The opds date use the standard --
T::Z + //and we want --
. That's easy, let's take the first 10 char + return date.substr(0, 10); +} + + #define VALUE(name) node.child(name).child_value() void Book::updateFromOpds(const pugi::xml_node& node, const std::string& urlHost) { @@ -141,7 +149,7 @@ void Book::updateFromOpds(const pugi::xml_node& node, const std::string& urlHost m_title = VALUE("title"); m_description = VALUE("description"); m_language = VALUE("language"); - m_date = VALUE("updated"); + m_date = fromOpdsDate(VALUE("updated")); m_creator = node.child("author").child("name").child_value(); for(auto linkNode = node.child("link"); linkNode; linkNode = linkNode.next_sibling("link")) { diff --git a/src/libxml_dumper.cpp b/src/libxml_dumper.cpp index 11680c11..96e580de 100644 --- a/src/libxml_dumper.cpp +++ b/src/libxml_dumper.cpp @@ -64,8 +64,6 @@ void LibXMLDumper::handleBook(Book book, pugi::xml_node root_node) { ADD_ATTR_NOT_EMPTY(entry_node, "creator", book.getCreator()); ADD_ATTR_NOT_EMPTY(entry_node, "publisher", book.getPublisher()); ADD_ATTR_NOT_EMPTY(entry_node, "faviconMimeType", book.getFaviconMimeType()); - ADD_ATTR_NOT_EMPTY(entry_node, "language", book.getLanguage()); - ADD_ATTR_NOT_EMPTY(entry_node, "language", book.getLanguage()); if (!book.getFavicon().empty()) ADD_ATTRIBUTE(entry_node, "favicon", base64_encode(book.getFavicon())); } else { diff --git a/src/opds_dumper.cpp b/src/opds_dumper.cpp index fcfde028..2105dc42 100644 --- a/src/opds_dumper.cpp +++ b/src/opds_dumper.cpp @@ -50,6 +50,13 @@ std::string gen_date_str() return is.str(); } +static std::string gen_date_from_yyyy_mm_dd(const std::string& date) +{ + std::stringstream is; + is << date << "T00:00::00:Z"; + return is.str(); +} + void OPDSDumper::setOpenSearchInfo(int totalResults, int startIndex, int count) { m_totalResults = totalResults; @@ -65,7 +72,7 @@ pugi::xml_node OPDSDumper::handleBook(Book book, pugi::xml_node root_node) { ADD_TEXT_ENTRY(entry_node, "title", book.getTitle()); ADD_TEXT_ENTRY(entry_node, "id", "urn:uuid:"+book.getId()); ADD_TEXT_ENTRY(entry_node, "icon", rootLocation + "/meta?name=favicon&content=" + book.getHumanReadableIdFromPath()); - ADD_TEXT_ENTRY(entry_node, "updated", date); + ADD_TEXT_ENTRY(entry_node, "updated", gen_date_from_yyyy_mm_dd(book.getDate())); ADD_TEXT_ENTRY(entry_node, "summary", book.getDescription()); auto content_node = entry_node.append_child("link");