4 桁の年とその年の週番号で構成される文字列を解析したいと考えています。ブースト日付/時刻 IO チュートリアルに従い、次のようなテスト例を作成しました。
std::string week_format = "%Y-W%W";
boost::date_time::date_input_facet<boost::gregorian::date, char> week_facet = boost::date_time::date_input_facet<boost::gregorian::date, char>(week_format);
std::stringstream input_ss;
input_ss.imbue(locale(input_ss.getloc(), &week_facet));
std::string input_week = "2004-W34";
input_ss.str(input_week);
boost::gregorian::date input_date;
input_ss >> input_date;
残念ながら、input_date
単に「2004-01-01」と出力され、年を解析しただけであることを暗示しています。私は何を間違っていますか?%W
入力で使用できませんか? (ドキュメントではそのようにマークされていません。)