//Creates a date time string in the form MMMM DD, YYYY, HH:MM:SS A.M.
//sSTR is a string tag
//StringConst is a String[18] array.
//StringConst[0] = "0"
//StringConst[1] = "Jan. "
//StringConst[2] = "Feb. "
//StringConst[3] = "Mar. "
//StringConst[4] = "Apr. "
//StringConst[5] = " May "
//StringConst[6] = "June "
//StringConst[7] = "July "
//StringConst[8] = "Aug. "
//StringConst[9] = "Sep. "
//StringConst[10] = "Oct. "
//StringConst[11] = "Nov. "
//StringConst[12] = "Dec. "
//StringConst[13] = "."
//StringConst[14] = " "
//StringConst[15] = ":"
//StringConst[16] = "A.M."
//StringConst[17] = "P.M."
//sPtr is a DINT
//CurrentWallClock[0] = year
//CurrentWallClock[1] = month
//CurrentWallClock[2] = day
//CurrentWallClock[3] = Hour
//CurrentWallClock[4] = Minute
//CurrentWallClock[5] = Second
GSV(WallClockTime,,DateTime,CurrentWallClock[0]); //Get the time from the system.
DTOS(CurrentWallClock[2], sSTR); //convert the current day to a string.
IF CurrentWallClock[2]<10 Then //append leading zero if day is less than 10
Concat(StringConst[0],sSTR, sSTR);
End_if;
dPtr:=CurrentWallClock[1]; //set pointer to month to point to string constants array for month name
CONCAT (StringConst[dPtr], sSTR, sDateTime); //Put together the month name with the date
CONCAT (sDateTime, StringConst[13], sDateTime); //Add a comma
CONCAT (sDateTime, StringConst[14], sDateTime); //Add a space
DTOS(CurrentWallClock[0], sSTR); //convert the year to a string
CONCAT (sDateTime, sSTR, sDateTime); //add in the year
CONCAT (sDateTime, StringConst[13], sDateTime); //Add a comma
CONCAT (sDateTime, StringConst[14], sDateTime); //Add a space
IF CurrentWallClock[3] > 12 Then //Adjust hour for P.M.
dPtr := CurrentWallClock[3] - 12;
Else
dPtr := CurrentWallClock[3];
End_if;
If dPtr < 10 Then
ConCat(sDateTime, StringConst[0], sDateTime); //add a leading zero for single digit hours
End_If;
DTOS(dPtr, sSTR); //convert hours to a string
CONCAT(sDateTime, sSTR, sDateTime); //add hours string to date time string;
CONCAT(sDateTime, StringConst[15], sDateTime); //Add a colon
If CurrentWallClock[4]<10 Then //Append a 0 if minutes is less than 10
Concat(sDateTime, StringConst[0], sDateTime);
End_if;
DTOS(CurrentWallClock[4], sSTR); //convert minutes to a string
CONCAT(sDateTime, sSTR, sDateTime); //append minutes to date time string.
CONCAT(sDateTime, StringConst[15], sDateTime); //Add a colon
If CurrentWallClock[5]<10 Then //Append a 0 if seconds is less than 10
Concat(sDateTime, StringConst[0], sDateTime);
End_if;
DTOS(CurrentWallClock[5], sSTR); //convert seconds to a string
CONCAT(sDateTime, sSTR, sDateTime); //append seconds to date time string
CONCAT (sDateTime, StringConst[14], sDateTime); //Add a space
If CurrentWallClock[2] > 12 Then // add in P.M. or A.M.
CONCAT(sDateTime, StringConst[17], sDateTime);
ELSE
CONCAT(sDateTime, StringConst[16], sDateTime);
End_IF;