bool WeatherApp::getWeatherString(String& forecastStr, const WeatherForecast& aWeatherForecast, uint8_t aWeatherPeriod) { if (aWeatherForecast.mValid) { const WeatherForecastPeriod& wfp = aWeatherForecast.mWeatherForecastPeriods[aWeatherPeriod]; RTC_date_time timestamp = RTC_clock::from_unixtime(wfp.timestamp + TIMEZONE_OFFSET); forecastStr = "Weather for " + getDayOfWeekString(timestamp) + " " + String(timestamp.hour) + ":" + ((timestamp.minute<10)?"0":"") + String(timestamp.minute) + "\n"; forecastStr += getWeatherTypeString(wfp.weatherType) + "\n"; forecastStr += "Temp: " + String(wfp.temperature) + " deg C\n"; forecastStr += "Feels: " + String(wfp.feelsLikeTemperature) + " deg C\n"; forecastStr += "Windspeed: " + String(wfp.windSpeed) + "mph\n"; forecastStr += String(wfp.screenRelativeHumidity) + "% humidity\n"; forecastStr += String(wfp.precipitationProbability) + "% chance of rain\n"; } else { forecastStr = "Sorry, no forecast received yet. Please try later (or wiggle the joystick to check for update)."; } return aWeatherForecast.mValid; }
String TimeStamp::toString() const { char str[25]; // snprintf_P(str, 25, PSTR("%s, %02d.%02d.%02d %02d:%02d:%02d"), getDayOfWeekString(), day, month, year, hours, minutes, seconds); strcpy(str, getDayOfWeekString()); strcat_P(str, PSTR(", 00.00.00 00:00:00")); str[4] += (day / 10); str[5] += (day % 10); str[7] += (month / 10); str[8] += (month % 10); str[10] += (year / 10); str[11] += (year % 10); str[13] += (hours / 10); str[14] += (hours % 10); str[16] += (minutes / 10); str[17] += (minutes % 10); str[19] += (seconds / 10); str[20] += (seconds % 10); return String(str); }