Compare commits

...

4 Commits

4 changed files with 15 additions and 13 deletions

View File

@ -844,11 +844,11 @@ class FTPServer : public TCPServer<T>
//We try to retrieve the last modification date //We try to retrieve the last modification date
const time_t fileModifDate = fileOrDir.getLastWrite(); const time_t fileModifDate = fileOrDir.getLastWrite();
struct tm *timeP = localtime(&fileModifDate); struct tm *timeP = localtime(&fileModifDate);
//Buffer necessary to store the month's three letter abbreviation //We get the month's three letter abbreviation
char month[4] = ""; uint32_t monthAbbreviation = monthNumTo3LetterAbbreviation(timeP->tm_mon + 1); //+1 because in the tm struct, month goes from 0 to 11 ...
#ifdef DEBUG_FTPS #ifdef DEBUG_FTPS
Serial.printf("Filename : %s, %s %d %d %d:%d\n", fileOrDir.name(), monthNumTo3LetterAbbreviation(month, timeP->tm_mon), timeP->tm_mon, timeP->tm_mday, timeP->tm_hour, timeP->tm_min); Serial.printf("Filename : %s, %s %d %d %d:%d\n", fileOrDir.name(), (char *)&monthAbbreviation, timeP->tm_mon, timeP->tm_mday, timeP->tm_hour, timeP->tm_min);
#endif #endif
char zero_prepended[3][3] = {"","",""}; char zero_prepended[3][3] = {"","",""};
@ -856,7 +856,7 @@ class FTPServer : public TCPServer<T>
client->_dataClient.printf("%crwxrwxrwx 1 owner esp8266 %d %s %s %s:%s %s\r\n", client->_dataClient.printf("%crwxrwxrwx 1 owner esp8266 %d %s %s %s:%s %s\r\n",
fileOrDir.isDirectory() ? 'd' : '-', fileOrDir.isDirectory() ? 'd' : '-',
fileOrDir.isDirectory() ? 0 : fileOrDir.size(), fileOrDir.isDirectory() ? 0 : fileOrDir.size(),
monthNumTo3LetterAbbreviation(month, timeP->tm_mon + 1), //+1 because in the tm struct, month goes from 0 to 11 ... (char *)&monthAbbreviation,
dateTimeFormater(zero_prepended[0],timeP->tm_mday,'0'), dateTimeFormater(zero_prepended[0],timeP->tm_mday,'0'),
dateTimeFormater(zero_prepended[1],!timeP->tm_hour ? 23 : timeP->tm_hour-1 ,'0'), dateTimeFormater(zero_prepended[1],!timeP->tm_hour ? 23 : timeP->tm_hour-1 ,'0'),
dateTimeFormater(zero_prepended[2],timeP->tm_min,'0'), dateTimeFormater(zero_prepended[2],timeP->tm_min,'0'),

View File

@ -72,16 +72,17 @@ char *lastIndexOf(char *str, const char character)
* The monthNumTo3LetterAbbreviation function takes the month number from 1 to 12 and returns the abbreviation in a 3 letter * The monthNumTo3LetterAbbreviation function takes the month number from 1 to 12 and returns the abbreviation in a 3 letter
* format. * format.
*/ */
char *monthNumTo3LetterAbbreviation(char *buffer, const uint8_t monthNumber) uint32_t monthNumTo3LetterAbbreviation(const uint8_t monthNumber)
{ {
static const char monthArray[][4] = {{"Jan"},{"Feb"},{"Mar"},{"Apr"},{"May"},{"Jun"},{"Jul"},{"Aug"},{"Sep"},{"Oct"},{"Nov"},{"Dec"}}; /**
* This array contains months as 3 letter abbreviations
if(buffer == NULL) return NULL; * Jan is written \0naJ and in hex : 0x006E614A an so on. They are thus 4Bytes aligned and easy to put and read back from prog mem :)
*/
static const uint32_t PROGMEM monthArray[] = {0x6E614A, 0x626546, 0x72614D, 0x727041, 0x79614D, 0x6E754A, 0x6C754A, 0x677541, 0x706553, 0x74634F, 0x766f4E, 0x636544};
uint32_t toReturn(0x6E614A); //Default to Jan.
if(monthNumber >= 1 && monthNumber <= 12) if(monthNumber >= 1 && monthNumber <= 12)
strcpy_P(buffer, monthArray[monthNumber-1]); toReturn = monthArray[monthNumber - 1];
else //If the month number is garbage, we return the first month of the year
strcpy_P(buffer, monthArray[0]);
return buffer; return toReturn;
} }

View File

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

View File

@ -36,6 +36,7 @@
#define SOFT_VERSION "1.6.4" //Added the forceRefresh() method to the ScreenManager Object #define SOFT_VERSION "1.6.4" //Added the forceRefresh() method to the ScreenManager Object
#define SOFT_VERSION "1.6.5" //Removed the sd card mount and unmount api calls, replaced with the sdCardAction api call which takes a parameter (does the same thing) #define SOFT_VERSION "1.6.5" //Removed the sd card mount and unmount api calls, replaced with the sdCardAction api call which takes a parameter (does the same thing)
#define SOFT_VERSION "1.6.6" //Removed useless INIT state that was like the LINE_BREAK state and added '-' as an allowed PARAM and VALUE character #define SOFT_VERSION "1.6.6" //Removed useless INIT state that was like the LINE_BREAK state and added '-' as an allowed PARAM and VALUE character
#define SOFT_VERSION "1.6.7" //Changed the way we store and return the 3 letter month abbreviation
#endif //VERSIONS_H #endif //VERSIONS_H