Added a new helper function to get month's 3 letter abbreviation

This commit is contained in:
anschrammh 2020-01-28 12:30:00 +01:00
parent 9e3676a1bb
commit 3f77399538
2 changed files with 17 additions and 0 deletions

View File

@ -67,3 +67,18 @@ char *lastIndexOf(char *str, const char character)
return last;
}
char *monthNumTo3LetterAbbreviation(char *buffer, const uint8_t monthNumber)
{
static const char monthArray[][4] = {{"Jan"},{"Feb"},{"Mar"},{"Apr"},{"May"},{"Jun"},{"Jul"},{"Aug"},{"Sep"},{"Oct"},{"Nov"},{"Dec"}};
if(buffer == NULL) return NULL;
if(monthNumber >= 1 && monthNumber <= 12)
strcpy_P(buffer, monthArray[monthNumber-1]);
else //Default is january
strcpy_P(buffer, monthArray[0]);
return buffer;
}

View File

@ -57,4 +57,6 @@ char *lastIndexOf(char *str, const char character);
char *dateTimeFormater(char *pointer, const uint8_t value, const char character);
char *monthNumTo3LetterAbbreviation(char *month, const uint8_t monthNumber);
#endif //DEFINITION_H