Convert the standard opds date to our format (YYYY-MM-DD)

This commit is contained in:
Matthieu Gautier 2018-12-11 17:02:02 +01:00
parent 0f812c6584
commit e6d7ba06fb
1 changed files with 9 additions and 1 deletions

View File

@ -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 <YYYY>-<MM>-<DD>T<HH>:<mm>:<SS>Z
//and we want <YYYY>-<MM>-<DD>. 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")) {