diff --git a/README.md b/README.md index 5960e8a..ffa5a76 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This library was based on the master branch of [NorthernWidget/DS3231](https://g * using standardized functions of the `time.h` library. * introduce a `struct tm` which holds all relevant date and time values. * restrucure comments, so that syntax highlighting works fine. -* add a `show_DateTime()` function with can be used to print a user specific(self defined) DateTime string easily. +* add a `strf_DateTime()` function with can be used to print a user specific(self defined) DateTime string easily. ## Contents @@ -275,7 +275,7 @@ further lists the DateTime class methods (for Documentation look into the src fi - getWeekDay() - getYearDay() - getDST() -- show_DateTime() +- strf_DateTime() - getUnixTime() - getY2KTime() diff --git a/examples/DateTime_Contructor_Test/DateTime_Contructor_Test.ino b/examples/DateTime_Contructor_Test/DateTime_Contructor_Test.ino index 1b214a5..dc260c6 100644 --- a/examples/DateTime_Contructor_Test/DateTime_Contructor_Test.ino +++ b/examples/DateTime_Contructor_Test/DateTime_Contructor_Test.ino @@ -122,9 +122,9 @@ void setup () { Serial.print("\n\nPrint Data via function of Struct tm:\n\t"); showTimeFormated(tstmp); - Serial.print("\nPrint Data via DataTime function :\n\t"); + Serial.print("\nPrint Data via DataTime function :\n\t"); char buffer[80]; - datetime.show_DateTime(buffer, sizeof(buffer)); + datetime.strf_DateTime(buffer, sizeof(buffer)); Serial.println(buffer); //Serial.print("\nPrint __DATE__ and __TIME__:\n"); diff --git a/examples/setEpoch/setEpoch.ino b/examples/setEpoch/setEpoch.ino index 8eb2da3..915146f 100644 --- a/examples/setEpoch/setEpoch.ino +++ b/examples/setEpoch/setEpoch.ino @@ -109,10 +109,10 @@ void setup () { showTimeFormated(tstmp); // Use smart print function from DateTime class - Serial.print("\nUse show_DateTime function:\n "); + Serial.print("\nUse strf_DateTime function:\n "); // provide a buffer char buffer[80]; - datetime.show_DateTime(buffer, sizeof(buffer)); + datetime.strf_DateTime(buffer, sizeof(buffer)); Serial.println(buffer); } diff --git a/keywords.txt b/keywords.txt index 8097202..cdacdb7 100644 --- a/keywords.txt +++ b/keywords.txt @@ -9,6 +9,7 @@ DateTime KEYWORD1 now KEYWORD2 getY2kTime KEYWORD2 getUnixTime KEYWORD2 +strf_DateTime KEYWORD2 getWeekDay KEYWORD2 getDST KEYWORD2 getSecond KEYWORD2 diff --git a/src/DS3231-RTC.cpp b/src/DS3231-RTC.cpp index 29bc062..bd01020 100644 --- a/src/DS3231-RTC.cpp +++ b/src/DS3231-RTC.cpp @@ -142,15 +142,17 @@ void DateTime::set_timstamps() { } /** - * @brief smart time print function based on the standard strftime function - * see: https://en.cppreference.com/w/cpp/chrono/c/strftime + * @brief function to format a DateTime string in an buffer based on the standard strftime function + * + * see: https://cplusplus.com/reference/ctime/strftime/ + * or: https://en.cppreference.com/w/cpp/chrono/c/strftime * * @param buffer buffer for time string * @param buffersize size of buffer * @param formatSpec define format see strftime * @return size_t lenth of used buffer */ -size_t DateTime::show_DateTime(char *buffer, size_t buffersize, const char *formatSpec) { +size_t DateTime::strf_DateTime(char *buffer, size_t buffersize, const char *formatSpec) { size_t len {strftime(buffer, buffersize, formatSpec, &_tm)}; return len; } diff --git a/src/DS3231-RTC.h b/src/DS3231-RTC.h index 946a3f1..8f0fd77 100644 --- a/src/DS3231-RTC.h +++ b/src/DS3231-RTC.h @@ -48,7 +48,7 @@ class DateTime { int8_t getWeekDay() const { return _tm.tm_wday; } int16_t getYearDay() const { return _tm.tm_yday; } int16_t getDST() const { return _tm.tm_isdst; } - size_t show_DateTime(char *buffer, size_t buffersize, const char *formatSpec = "%a %h %d %T %Y"); + size_t strf_DateTime(char *buffer, size_t buffersize, const char *formatSpec = "%a %h %d %T %Y"); // time_t value as seconds since 1/1/2000 time_t getY2kTime() const { return _y2k_timestamp; }