Advertisement
serikov

Untitled

Jun 23rd, 2013
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1.  boost::regex xRegEx1("\"([0-2][0-9])([0-5][0-9])\\s([AP]M)\"");
  2.                boost::smatch xResults;
  3.                if (boost::regex_match(time, xResults, xRegEx1)) {
  4.                     cout<<"xResults[0] is "<<xResults[0]<<"\n";
  5.                     cout<<"xResults[1] is "<<xResults[1]<<"\n";
  6.                     cout<<"xResults[2] is "<<xResults[2]<<"\n";
  7.                     cout<<"xResults[3] is "<<xResults[3]<<"\n";
  8.                    hours = strtol(xResults[1].str().c_str(), NULL, 10);
  9.                    minutes = strtol(xResults[2].str().c_str(), NULL, 10);
  10.                    if (strcmp(xResults[3].str().c_str(), "PM")==0)  hours = hours + 12;
  11.                    return true;
  12.                } else {
  13.                 cout<<"Incorrect time format\n";
  14.                 return false;
  15.                 }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement