Skip to content

Commit 76221f6

Browse files
committed
Add String cast operator or RTCTime
Former-commit-id: 74ef07c
1 parent b0e991a commit 76221f6

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

libraries/RTC/src/RTC.h

+8
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ class RTCTime {
114114
* @return String The date and time in the format YYYY-MM-DDTHH:MM:SS.
115115
*/
116116
arduino::String toString() const;
117+
118+
/**
119+
* @brief Returns the ISO 8601 string representation of the date and time
120+
* by calling the toString() method.
121+
* @return String The date and time in the format YYYY-MM-DDTHH:MM:SS.
122+
*/
123+
operator arduino::String() const;
124+
};
117125

118126
enum class Period {
119127
ONCE_EVERY_2_SEC,

libraries/RTC/src/RTClock.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,10 @@ arduino::String RTCTime::toString() const {
403403
return formattedTime;
404404
}
405405

406+
RTCTime::operator String() const{
407+
return toString();
408+
}
409+
406410
/* -------------------------------------------------------------------------- */
407411
/* RTClass */
408412
/* -------------------------------------------------------------------------- */

0 commit comments

Comments
 (0)