Try "C++ pointer dereference operator".
Maybe that's not such a good search term.
This might help:- Class member access operator (->) overloading in C++
And here's a better example. It prints "00:42:28 Sun 04 Sep 2016 ausNSW"
(My time zone - must be bedtime.
)
#include <Timezone.h> //https://github.com/JChristensen/Timezone
//Australia Eastern Time Zone (Sydney, Melbourne)
TimeChangeRule aEDT = {"AEDT", First, Sun, Oct, 2, 660}; //UTC + 11 hours
TimeChangeRule aEST = {"AEST", First, Sun, Apr, 3, 600}; //UTC + 10 hours
Timezone ausQLD(aEST, aEST);
Timezone ausNSW(aEDT, aEST);
//Australia Central Time Zone (Darwin)
TimeChangeRule aCDT = {"ACDT", First, Sun, Oct, 2, 630}; //UTC + 10.5 hours
TimeChangeRule aCST = {"ACST", First, Sun, Apr, 3, 570}; //UTC + 9.5 hours
Timezone ausNT(aCST, aCST);
Timezone ausSA(aCDT, aCST);
//Australia Western Time Zone (Perth)
TimeChangeRule aWST = {"AWST", First, Sun, Apr, 3, 480}; //UTC + 8 hours
Timezone ausWA(aWST, aWST);
#define NUMBER_OF_TIME_ZONES 5
Timezone* timeZones_arr[NUMBER_OF_TIME_ZONES] =
{
&ausQLD,
&ausNSW,
&ausNT,
&ausSA,
&ausWA
};
char zoneList[NUMBER_OF_TIME_ZONES][7] =
{
"ausQLD",
"ausNSW",
"ausNT",
"ausSA",
"ausWA"
};
TimeChangeRule *tcr; //pointer to the time change rule, use to get the TZ abbrev
time_t utc;
void setup()
{
Serial.begin(115200);
byte zoneIndex = 1;
utc = now();
setTime(timeZones_arr[zoneIndex]->toUTC(compileTime()));
printTime(timeZones_arr[zoneIndex]->toLocal(utc, &tcr), tcr -> abbrev, zoneList[zoneIndex]);
}
void loop()
{
}
//Function to return the compile date and time as a time_t value
time_t compileTime(void)
{
#define FUDGE 25 //fudge factor to allow for compile time (seconds, YMMV)
char *compDate = __DATE__, *compTime = __TIME__, *months = "JanFebMarAprMayJunJulAugSepOctNovDec";
char chMon[3], *m;
int d, y;
tmElements_t tm;
time_t t;
strncpy(chMon, compDate, 3);
chMon[3] = '\0';
m = strstr(months, chMon);
tm.Month = ((m - months) / 3 + 1);
tm.Day = atoi(compDate + 4);
tm.Year = atoi(compDate + 7) - 1970;
tm.Hour = atoi(compTime);
tm.Minute = atoi(compTime + 3);
tm.Second = atoi(compTime + 6);
t = makeTime(tm);
return t + FUDGE; //add fudge factor to allow for compile time
}
//Function to print time with time zone
void printTime(time_t t, char *tz, char *loc)
{
sPrintI00(hour(t));
sPrintDigits(minute(t));
sPrintDigits(second(t));
Serial.print(' ');
Serial.print(dayShortStr(weekday(t)));
Serial.print(' ');
sPrintI00(day(t));
Serial.print(' ');
Serial.print(monthShortStr(month(t)));
Serial.print(' ');
Serial.print(year(t));
Serial.print(' ');
Serial.print(tz);
Serial.print(' ');
Serial.print(loc);
Serial.println();
}
//Print an integer in "00" format (with leading zero).
//Input value assumed to be between 0 and 99.
void sPrintI00(int val)
{
if (val < 10) Serial.print('0');
Serial.print(val, DEC);
return;
}
//Print an integer in ":00" format (with leading zero).
//Input value assumed to be between 0 and 99.
void sPrintDigits(int val)
{
Serial.print(':');
if(val < 10) Serial.print('0');
Serial.print(val, DEC);
}