NTPClient
NTPClient copied to clipboard
Added two new methods to return Date and Time as a struct and get formatted Date Time string with a given format
Added bellow two methods to return Date and Time information together as a struct and formatted datetime string with a given format.
getDateTimegetFormattedDateTime
Additional context
Additional requests
- https://github.com/arduino-libraries/NTPClient/pull/94#issuecomment-1126950276
- https://github.com/arduino-libraries/NTPClient/pull/94#issuecomment-1128466438
- https://github.com/arduino-libraries/NTPClient/pull/94#issuecomment-1259850449
- https://github.com/arduino-libraries/NTPClient/pull/94#issuecomment-1296254495
- https://github.com/arduino-libraries/NTPClient/pull/94#issuecomment-1509963424
- https://github.com/arduino-libraries/NTPClient/pull/94#issuecomment-2495481476
Please add the new function names to keywords.txt, using a true tab as a separator between the keyword and the identifier: https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification#keywordstxt-format
Added new two methods to the keywords.txt
Thanks for the review and the comments. Do we know when these changes going to merge and will be publicly available ?
Hello,
is it possible to add this possiblility ?
in NTPClient.h
/** * Return the date time from the epochtime value as a String with the given format (Ex: %Y/%m/%d %H:%M:%S) */ String getFormattedDateTime(const char* dateTimeFormat, time_t t) const;
in NTPClient.cpp
String NTPClient::getFormattedDateTime(const char* dateTimeFormat, time_t t = 0) const { struct tm * ts; time_t rawTime = t ? t : this->getEpochTime(); ts = localtime(&rawTime); char buf[64]; strftime(buf, sizeof(buf), dateTimeFormat, ts); return String(buf); }
that may be useful
Hello, is it possible to add this possiblility ? in NTPClient.h
/** * Return the date time from the epochtime value as a String with the given format (Ex: %Y/%m/%d %H:%M:%S) */ String getFormattedDateTime(const char* dateTimeFormat, time_t t) const;in NTPClient.cpp
String NTPClient::getFormattedDateTime(const char* dateTimeFormat, time_t t = 0) const { struct tm * ts; time_t rawTime = t ? t : this->getEpochTime(); ts = localtime(&rawTime); char buf[64]; strftime(buf, sizeof(buf), dateTimeFormat, ts); return String(buf); }that may be useful
I think this is something more of a utility functions which NTPClient not directly involving. Passing epochtime from outside and getting it formatted is not part of a job in NTPClient.
Would be nice if we could have this in.
'class NTPClient' has no member named 'getFormattedDate'; did you mean 'getFormattedTime'?
getFormattedDateTime method will return the formatted date, time or datetime string according to the given format.
Ex: datetime patter: %Y/%m/%d %H:%M:%S or %Y-%m-%d %H:%M:%S date pattern: %Y/%m/%d time pattern: %H:%M:%S
will this enhancement be merged to main branch?
will this enhancement be merged to main branch?
I'm also waiting for the same
Not merged yet?
Is there any particular reason why that wasn't merged yet?
Is anything holding back timeClient.getFormattedDateTime()?