make time setting better

Im using a modificated void for setting the time of a DS3232 RTC IC. The problem is, that the code is very buggy, when the circuit is reset or someting is transmitted over serial. Because of that, i want to use a preffix and suffix with the time code.

Currently my windows cmd applications sends:1329002001137
I want this convert to: S1329002001137X

Could someone help me with this? My current code is below!

void setSerialTime() {
  if (Serial.available() > 0) {
    int i = 0;
    //read incoming
    memset(incoming, 0, sizeof(incoming));
    //time will be send in format HHmmssddMMyyw, z.B. 1329002001137
       
    while (Serial.available() > 0 && i < sizeof(incoming) - 1) {
      incoming[i] = Serial.read();
      i++;
      delay(3);
    }
    
    char SIhr[3] = {};
    char SImin[3] = {};
    char SIsec[3] = {};
    char SIday[3] = {};
    char SImonth[3] = {};
    char SIyr[3] = {};
    char SIweekday[2] = {};

    
    SIhr[0] = incoming[0];
    SIhr[1] = incoming[1];
    SImin[0] = incoming[2];
    SImin[1] = incoming[3];
    SIsec[0] = incoming[4];
    SIsec[1] = incoming[5];
    SIday[0] = incoming[6];
    SIday[1] = incoming[7];
    SImonth[0] = incoming[8];
    SImonth[1] = incoming[9];
    SIyr[0] = incoming[10];
    SIyr[1] = incoming[11];
    SIweekday[0] = incoming[12];
  

    byte Ssecond =      atoi(SIsec); //0-59
    byte Sminute =      atoi(SImin); //0-59
    byte Shour =        atoi(SIhr); //0-23
    byte SweekDay =     atoi(SIweekday); //0-6 -> sunday - Saturday
    byte SmonthDay =    atoi(SIday); //1-31
    byte Smonth =       atoi(SImonth); //1-12
    byte Syear  =       atoi(SIyr); //0-99


        RTCsetTime(Ssecond, Sminute, Shour, SweekDay, SmonthDay, Smonth, Syear);
        printTime();
        printTime();
      
    }
}

Im using a modificated void

A what?

Currently my windows cmd applications sends:1329002001137
I want this convert to: S1329002001137X

Send an 'S', send your string, then send a 'X'.

AWOL:
A what? Send an 'S', send your string, then send a 'X'.

Yes, like i said, the sending part works, but how can i check if the X and S are there?

The function (void) is not mine, i just modification the names and variables.

how can i check if X and S are there, before executing RTCsetTime

The function (void) is not mine, i just modification the names and variables.

No one really gives a shit what the function return type is. The thing is called a function. You sound like a doofus when you call them voids.

The digitalRead() function returns an int. You would not call that function an int, would you? Then don't call functions that return nothing voids.

sgt_johnny:

    //time will be send in format HHmmssddMMyyw, z.B. 1329002001137

just send a simple Unix timestamp and forget about all that parsing you are doing.