4 #include <boost/algorithm/string/classification.hpp>
5 #include <boost/algorithm/string/split.hpp>
6 #include <boost/algorithm/string/replace.hpp>
19 if (moves().empty()) {
20 addWithNewLine(initial_comment, msg);
23 comments.resize(moves().size());
24 comments.back() = msg;
28 move_info.resize(moves().size());
29 if (!move_info.empty()) {
30 move_info.back() = info;
35 times.resize(moves().size());
41 std::vector<std::string> values;
42 boost::algorithm::split(values, date_str, boost::algorithm::is_any_of(
"/"));
43 if (values.size() < 3) {
44 std::cerr <<
"ERROR: Invalid date format found: "
50 }
else if (values.size() > 3) {
51 std::cerr <<
"WARNING: Invalid date format found: "
58 for (std::string& value: values) {
62 for (
size_t i=0; i<kanji.
size(); ++i)
63 boost::algorithm::replace_all(value, kanji[i], std::string(1,
char(
'0'+i)));
69 year = stoi(values[0]);
70 month = stoi(values[1]);
71 if (month == 0) month = 1;
72 if (
"??" == values[2]) {
73 std::cerr <<
"WARNING: Invalid date format found: "
80 }
else if (values[2].size() > 2) {
81 std::cerr <<
"WARNING: Invalid date format found: "
87 day = stoi(values[2].substr(0,2));
89 day = stoi(values[2]);
91 if (day == 0) day = 1;
92 start_date = boost::gregorian::date(year, month, day);
93 assert(!start_date.is_special());
95 catch (boost::gregorian::bad_day_of_month& ebdm) {
96 std::cerr <<
"Bad day of month: "
101 << ebdm.what() << std::endl;
103 catch (std::exception& e) {
104 std::cerr <<
"Invalid date format found: "
109 << e.what() << std::endl;