Better handling of date/year in tags
This commit is contained in:
+1
-25
@@ -23,33 +23,9 @@
|
||||
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include "Utils.hpp"
|
||||
|
||||
template<>
|
||||
boost::optional<Wt::WDate> readAs(const std::string& str)
|
||||
{
|
||||
const std::vector<std::string> formats = {
|
||||
"yyyy-MM-dd",
|
||||
"yyyy/MM/dd",
|
||||
"yyyy-MM",
|
||||
"yyyy/MM",
|
||||
"yyyy"
|
||||
};
|
||||
|
||||
for (auto format : formats)
|
||||
{
|
||||
auto date = Wt::WDate::fromString(str, format);
|
||||
|
||||
if (!date.isValid())
|
||||
continue;
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
return boost::none;
|
||||
}
|
||||
|
||||
bool readList(const std::string& str, const std::string& separators, std::list<std::string>& results)
|
||||
{
|
||||
std::string curStr;
|
||||
|
||||
@@ -57,7 +57,3 @@ boost::optional<T> readAs(const std::string& str)
|
||||
return res;
|
||||
}
|
||||
|
||||
template<>
|
||||
boost::optional<Wt::WDate> readAs(const std::string& str);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user