Time Format

Looking for some help with the formatting of the time returned from the Yun.

When converting the string from the integer I get the following out put:

looping...
20:24:05
3392
2400
5

First line is the string from the time function.
Second line is supposed to be the two digit hour (times 1000), which is not correct.
Third line is the two digit minute (times 100), which is correct
Fourth line is the two digit second (minus the leading zero), mostly correct

What is the conversion I should be using to get the correct hour?

/* Yun specific */
#include <Bridge.h>
#include <Process.h>
#include <Console.h>

int hours, minutes, seconds;  // for the results
int aStart = 61000;          // Program A start time
int bStart = 51000;          // Program B start time
int cStart = 154000;          // Program C start time
int strtDev = 200;
String flStart;
String program;

void setup() {
  Bridge.begin();
  Console.begin();
  while(!Console);
  Console.println("Setup Complete...");  
}

void loop() {
      Console.println("looping...");
      flStart = getTimeStamp();
      Console.println(flStart);
    // find the colons:
    int firstColon = flStart.indexOf(":");
    int secondColon = flStart.lastIndexOf(":");

    // get the substrings for hour, minute second:
    String hourString = flStart.substring(0, firstColon);
    String minString = flStart.substring(firstColon + 1, secondColon);
    String secString = flStart.substring(secondColon + 1);

    // convert to ints
    int intTime;
    long int inthours;
    int intminutes;
    int intseconds;
    
    hours = hourString.toInt();
    hours *= 10000;
    minutes = minString.toInt();
    minutes *= 100;
    seconds = secString.toInt();
    inthours = hours;
    intminutes = minutes;
    intseconds = seconds;
    
    intTime += hours;
    intTime += minutes;
    intTime += seconds;
      Console.println(inthours);
      Console.println(intminutes);
      Console.println(intseconds);
      Console.println(intTime);
      delay (1000);
}
///////////////////////////////////////////////////////////////////////////////
// This function return a string with the time stamp
String getTimeStamp() {
  String result;
  Process time;
  // date is a command line utility to get the date and the time
  // in different formats depending on the additional parameter
  time.begin("date");
  time.addParameter("+%T");  // parameters: D for the complete date mm/dd/yy
  //             T for the time hh:mm:ss
  time.run();  // run the command

  // read the output of the command
  while (time.available() > 0) {
    char c = time.read();
    if (c != '\n')
      result += c;
  }

  return result;
}

Datatype overflow problem

int -32,768 to 32,767
long -2,147,483,648 to 2,147,483,647.

change from int to long and give it try.

lexical43:

int cStart = 154000;          // Program C start time

To be precise on what sonyyu mentioned, the above line is already wrong. It should actually generate a warning message from the compiler...

Ralf