Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Variables for calculation.
- int timeDif; int startTime; int endTime;
- int startHour; int startMin; int startSec;
- int endHour; int endMin; int endSec;
- int startDay; int endDay;
- // Part of the Extra Credit. Finding the day values.
- startDay = stoi(startDateValue.substr(6, 2));
- endDay = stoi(dateValue.substr(6, 2));
- // Start time individual values from string to integer.
- startHour = stoi(startDateValue.substr(8, 2));
- startMin = stoi(startDateValue.substr(10, 2));
- startSec = stoi(startDateValue.substr(12, 2));
- // Start time in seconds format.
- startTime = (((startHour * 60) + startMin) * 60) + startSec;
- // End time individual values from string to integer.
- endHour = stoi(dateValue.substr(8, 2));
- endMin = stoi(dateValue.substr(10, 2));
- endSec = stoi(dateValue.substr(12, 2));
- // End time in seconds format.
- endTime = (((endHour * 60) + endMin) * 60) + endSec;
- // Second part of extra credit.
- // If the days do not equal each other,
- // a days worth of seconds is added to the
- // end time to account for calls going over night.
- if (startDay != endDay) {
- endTime = endTime + 86400;
- }
- // The final calculation of the duration.
- timeDif = endTime - startTime;
- return timeDif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement