adafruit / RTClib

A fork of Jeelab's fantastic RTC Arduino library
MIT License
798 stars 709 forks source link

Examples that contain only C strings, not Strings? #295

Open terrypin999 opened 12 months ago

terrypin999 commented 12 months ago

Not an 'issue', sorry, but I need advice on an embarrasingly basic aspect: which if any of the Examples include Strings? I've been trouble-shooting erratic behaviour for days of the sort I gather is often down to the use of Strings. My current project (which includes five other libraries) has this function, derived partly from ds3231.ino and other extracts:

`void updateRTC() // Use RTC to get date & time { DateTime now = rtc.now();

//buffer can be defined using following combinations: //--------------------------------------------------- //hh - the hour with a leading zero (00 to 23) //mm - the minute with a leading zero (00 to 59) //ss - the whole second with a leading zero where applicable (00 to 59) //YYYY - the year as four digit number //YY - the year as two digit number (00-99) //MM - the month as number with a leading zero (01-12) //MMM - the abbreviated English month name ('Jan' to 'Dec') //DD - the day as number with a leading zero (01 to 31) //DDD - the abbreviated English day name ('Mon' to 'Sun')

Day = now.day(); Month = now.month(); Year = now.year(); Secs = now.second(); Hours = now.hour(); Minutes = now.minute(); dofweek = daysOfTheWeek[now.dayOfTheWeek()];

// Calculate the current day of year, doy doy = dayOfYear(Day, Month, Year);

constructPaddedRTCstrings();

// Serial.print(F("From upDateRTC: doy = ")); // Serial.println(doy); // myDate = ""; // Reset myTime = ""; // Reset

} // End updateRTC `

Which of these are Strings not strings?

If any are Strings, I want to rewrite that function (and many others0 with strings. Which Examples should I focus on for that please?

edgar-bonet commented 12 months ago

You can search the provided examples for the word String. You will see that only two of them use String, and this usage is unrelated to RTClib itself. Within the library, only DateTime::timestamp() deals with String objects: it returns a text-formatted timestamp as a String.

If you are having issues with Arduino String objects, this is the wrong venue to ask for help. This is an issue tracker meant for filing bugs and requesting features on RTClib. I suggest you visit the Arduino forum or the Arduino stack exchange.