I want to use JChristensen TimeZone lib and make the user fill it in over a webconnection.
This is the format the TimeZone.lib needs:
struct TimeChangeRule
{
char abbrev[6]; // five chars max
uint8_t week; // First, Second, Third, Fourth, or Last week of the month
uint8_t dow; // day of week, 1=Sun, 2=Mon, ... 7=Sat
uint8_t month; // 1=Jan, 2=Feb, ... 12=Dec
uint8_t hour; // 0-23
int offset; // offset from UTC in minutes
};
What I get from user input is a String (currentLine), which I cut into parts. It's succesfull for uint8_t like this.
week_Summer= (uint8_t)(currentLine.substring(place2+6, place3).toInt());
// some more conversions and then:
TimeChangeRule UserSummer = {abbrev_Summer,week_Summer,dow_Summer,month_Summer,hour_Summer,offset_Summer};
It's not succesfull for the char array. This is what I've tried:
char abbrev_Summer[6]; // five chars max
currentLine.substring(place1+7, place2).toCharArray(abbrev_Summer, 5);
TimeChangeRule UserSummer = {abbrev_Summer,week_Summer,dow_Summer,month_Summer,hour_Summer,offset_Summer};
// error is in last line: array must be initialized with a brace-enclosed initializer
Then I tried:
char abbrev_Summer={0};
currentLine.substring(place1+7, place2).toCharArray(abbrev_Summer, 5);
TimeChangeRule UserSummer = {abbrev_Summer,week_Summer,dow_Summer,month_Summer,hour_Summer,offset_Summer};
// error in second line is: invalid conversion from 'char' to 'char*' [-fpermissive]
Then
char abbrev_Summer={0};
strncpy(abbrev_Summer,(currentLine.substring(place1+7, place2)).c_str(),6);
TimeChangeRule UserSummer = {abbrev_Summer,week_Summer,dow_Summer,month_Summer,hour_Summer,offset_Summer};
// error in second line is: invalid conversion from 'char' to 'char*' [-fpermissive]
Then I tried a whole bunch of trial-and-error code from different parts of the web concluding that I don't exactly know what to do here....
EDIT: This is all on the ESP32.