Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Time {
- public:
- Time();
- bool Parse(string time) {
- hours = 0;
- minutes = 0;
- boost::regex xRegEx1("^([0-2][0-9])([0-5][0-9])(\\s[AP]M)");
- boost::smatch xResults;
- if (!boost::regex_match(time, xResults, xRegEx1)) {
- hours = strtol(xResults[1].str().c_str(), NULL, 10);
- minutes = strtol(xResults[2].str().c_str(), NULL, 10);
- if (strcmp(xResults[3].str().c_str(), "PM")==0) hours = hours + 12;
- return true;
- } else return false;
- }
- int GetHours () {
- return hours;
- }
- int GetMinutes() {
- return hours;
- }
- private:
- int hours;
- int minutes;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement