[locale] how to read a local date from an istream?

Hi, With boost::locale we can output a localized date: double d=...; std::cout<<boost::locale::as::date<<d; but how can I read a date from a string? std::cin>>boost::locale::as::date>>d; does not work. It stops reading at the first "/". For example, this small program #include <iostream> #include <sstream> #include <boost/locale/formatting.hpp> #include <boost/locale/generator.hpp> int main(int argc, char **argv) { boost::locale::generator gen; gen.categories(); auto loc = gen(""); double date = 5.; // default value to see if it changes std::istringstream iss("2/11/2017"); // November 1st, 2017 in French iss.imbue(loc); iss >> boost::locale::as::date >> boost::locale::as::local_time >> date; std::cout.imbue(loc); std::cout << "as_posix: " << boost::locale::as::posix << date << "\n" << "as_date: " << boost::locale::as::date << date << "\n"; return 0; } outputs as_posix: 2 as_date: 01/01/1970 instead of as_posix: 1509617233 (may be different) as_date: 02/11/2017 F
participants (1)
-
Frédéric