FUNCTION "FC_TimeAsString" : String
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_TEMP 
      tInt : DInt;
      tDTL {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL;
      sTmp : String[10];
   END_VAR


BEGIN
	#tInt := RD_LOC_T(#tDTL);
	
	#sTmp := UINT_TO_STRING(#tDTL.HOUR);
	IF #tDTL.HOUR < 10 THEN
	    #FC_TimeAsString[1] := '0';
	    #FC_TimeAsString[2] := #sTmp[2];
	ELSE
	    #FC_TimeAsString[1] := #sTmp[2];
	    #FC_TimeAsString[2] := #sTmp[3];
	END_IF;
	
	#FC_TimeAsString[3] := ':';
	
	#sTmp := USINT_TO_STRING(#tDTL.MINUTE);
	IF #tDTL.MINUTE < 10 THEN
	    #FC_TimeAsString[4] := '0';
	    #FC_TimeAsString[5] := #sTmp[2];
	ELSE
	    #FC_TimeAsString[4] := #sTmp[2];
	    #FC_TimeAsString[5] := #sTmp[3];
	END_IF;
	
	#FC_TimeAsString[6] := ':';
	
	#sTmp := USINT_TO_STRING(#tDTL.SECOND);
	IF #tDTL.SECOND < 10 THEN
	    #FC_TimeAsString[7] := '0';
	    #FC_TimeAsString[8] := #sTmp[2];
	ELSE
	    #FC_TimeAsString[7] := #sTmp[2];
	    #FC_TimeAsString[8] := #sTmp[3];
	END_IF;
	
	#FC_TimeAsString[9] := ',';
	
	#sTmp := UDINT_TO_STRING(#tDTL.NANOSECOND);
	IF #tDTL.NANOSECOND < 1000000 THEN
	    #FC_TimeAsString[10] := '0';
	    #FC_TimeAsString[11] := '0';
	    #FC_TimeAsString[12] := '0';
	ELSIF #tDTL.NANOSECOND < 10000000 THEN
	    #FC_TimeAsString[10] := '0';
	    #FC_TimeAsString[11] := '0';
	    #FC_TimeAsString[12] := #sTmp[2];
	ELSIF #tDTL.NANOSECOND < 100000000 THEN
	    #FC_TimeAsString[10] := '0';
	    #FC_TimeAsString[11] := #sTmp[2];
	    #FC_TimeAsString[12] := #sTmp[3];
	ELSE
	    #FC_TimeAsString[10] := #sTmp[2];
	    #FC_TimeAsString[11] := #sTmp[3];
	    #FC_TimeAsString[12] := #sTmp[4];
	END_IF;
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
END_FUNCTION

