fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. #include <ctime>
  4. #include <iomanip>
  5. #include <locale>
  6. #include <sstream>
  7.  
  8. bool parseAscTimeDate(std::tm& tm, const std::string& str) {
  9. std::istringstream ss(str);
  10. //ss.imbue(std::locale("en_US.UTF8")); //try timezone?
  11. ss >> std::get_time(&tm, "%a %b %d %H:%M:%S %Y");
  12. return !ss.fail();
  13. }
  14.  
  15. int main()
  16. {
  17. /* ANSI C's asctime format */
  18. std::tm tm;
  19. if (parseAscTimeDate(tm, "Sun Nov 06 08:49:37 1994"))
  20. std::cout << "Ok!" << std::endl;
  21. else
  22. std::cout << "Wrong!" << std::endl;
  23. }
Success #stdin #stdout 0s 16072KB
stdin
Standard input is empty
stdout
Ok!