Added a new function to format time with a leading zero

This commit is contained in:
anschrammh 2019-09-01 21:28:30 +02:00
parent 5cc7d1403a
commit 4e8a898b26
2 changed files with 18 additions and 0 deletions

View File

@ -33,3 +33,19 @@ char *addChar(char *pointer, const char character)
return pointer;
}
char *dateTimeFormater(char *pointer, const uint8_t value, const char character)
{
if(pointer == NULL)
return pointer;
if(value < 10)
{
sprintf(pointer,"%d", value);
*(pointer+1) = *(pointer);*(pointer) = character;*(pointer+2) = '\0';
}
else
sprintf(pointer,"%d", value);
return pointer;
}

View File

@ -66,4 +66,6 @@ typedef struct powerInfo
char *addChar(char *pointer, const char character);
char *dateTimeFormater(char *pointer, const uint8_t value, const char character);
#endif //DEFINITION_H