// computeSplitTime.cc
// P. Conrad 03/06/06
// separately compiled computeSplitTime() function

#include <cstring> // strtok
#include <cstdlib> // atoi and atof
using namespace std;

double computeSplitTime(const char *  const splitTimePtr)
{
  
  char splitTimeCopy[1024]; // over-engineered in a big way

  strcpy(splitTimeCopy, splitTimePtr);
  
  // now proceed with the rest of the function...

  double result;

  // use strtok to divide the string into the first part
  // which is in minutes, and the second part which is in seconds.

  // for example, 1:51.9 will be divided into 1\051.9

  char *firstPart;
  char *secondPart;
  
  firstPart = strtok(splitTimeCopy,":");
  secondPart = strtok(NULL,":");

  // compute the result by converting firstPart to a number
  // and multiplying by 60, and add to second part
  // use atof on the second part, becuase it is a double
  // (yeah, go figure... there is no atod... atof returns not
  //    a float, but rather, a double)

  result = atoi(firstPart) * 60 + atof(secondPart);

  return result;
}









