fork download
  1. #include <algorithm>
  2. #include <cctype>
  3. #include <ctime>
  4. #include <iostream>
  5. #include <iomanip>
  6. #include <limits>
  7. #include <sstream>
  8. #include <string>
  9.  
  10. using namespace std;
  11.  
  12. int main() {
  13. tm tmbuf{};
  14. stringstream str("20:48:01.469 UTC MAR 31 2016");
  15. string tm_mon;
  16.  
  17. str >> get_time(&tmbuf, "%T");
  18.  
  19. str.ignore(std::numeric_limits<std::streamsize>::max(), 'C');
  20.  
  21. str >> tm_mon >> get_time(&tmbuf, "%d %Y");
  22.  
  23. for (const auto& i : { "JAN"s, "FEB"s, "MAR"s, "APR"s, "MAY"s, "JUN"s, "JUL"s, "AUG"s, "SEP"s, "OCT"s, "NOV"s, "DEC"s }) {
  24. if (equal(cbegin(tm_mon), cend(tm_mon), cbegin(i), cend(i), [](const unsigned char a, const unsigned char b) { return toupper(a) == b; })) break;
  25. ++tmbuf.tm_mon;
  26. }
  27.  
  28. cout << put_time(&tmbuf, "%m-%d-%Y") << endl;
  29. }
Success #stdin #stdout 0s 3420KB
stdin
Standard input is empty
stdout
03-31-2016