About Daylight Saving Time, few days ago I write this to verify my DLST function.
//#########################################################################
boolean DLST(int y, byte m, byte d, byte h=2)
{ // before 1976 it is not always last Sunday of March and October at 01h00 UTC
byte s = (31 - (5 * y /4 + 4) % 7); // spring
byte a = (31 - (5 * y /4 + 1) % 7); // autumn
if
(
(
(m > 3)
&&
(m < 10)
)
||
(
(m == 3)
&&
(d > s)
)
||
(
(m == 3)
&&
(d == s)
&&
(h >= 1)
)
||
(
(m == 10)
&&
(d < a)
)
||
(
(m == 10)
&&
(d == a)
&&
(h < 1)
)
)
{ return true; }
else
{ return false; }
}
//#########################################################################
////////////////////////////////////////////////////////////////////////////////////////
void setup()
{ Serial.begin(9600);
while (!Serial);
/* theese dates for Europe come from internet almanach */
char* t[] = {
"26/03/2000 (GMT+2)",
"29/10/2000 (GMT+1)",
"25/03/2001 (GMT+2)",
"28/10/2001 (GMT+1)",
"31/03/2002 (GMT+2)",
"27/10/2002 (GMT+1)",
"30/03/2003 (GMT+2)",
"26/10/2003 (GMT+1)",
"28/03/2004 (GMT+2)",
"31/10/2004 (GMT+1)",
"27/03/2005 (GMT+2)",
"30/10/2005 (GMT+1)",
"26/03/2006 (GMT+2)",
"29/10/2006 (GMT+1)",
"25/03/2007 (GMT+2)",
"28/10/2007 (GMT+1)",
"30/03/2008 (GMT+2)",
"26/10/2008 (GMT+1)",
"29/03/2009 (GMT+2)",
"25/10/2009 (GMT+1)",
"28/03/2010 (GMT+2)",
"31/10/2010 (GMT+1)",
"27/03/2011 (GMT+2)",
"30/10/2011 (GMT+1)",
"25/03/2012 (GMT+2)",
"28/10/2012 (GMT+1)",
"31/03/2013 (GMT+2)",
"27/10/2013 (GMT+1)",
"30/03/2014 (GMT+2)",
"26/10/2014 (GMT+1)",
"29/03/2015 (GMT+2)",
"25/10/2015 (GMT+1)",
"27/03/2016 (GMT+2)",
"30/10/2016 (GMT+1)",
"26/03/2017 (GMT+2)",
"29/10/2017 (GMT+1)",
"25/03/2018 (GMT+2)",
"28/10/2018 (GMT+1)",
"31/03/2019 (GMT+2)",
"27/10/2019 (GMT+1)",
"29/03/2020 (GMT+2)",
"25/10/2020 (GMT+1)",
"28/03/2021 (GMT+2)",
"31/10/2021 (GMT+1)",
"27/03/2022 (GMT+2)",
"30/10/2022 (GMT+1)",
"26/03/2023 (GMT+2)",
"29/10/2023 (GMT+1)",
"31/03/2024 (GMT+2)",
"27/10/2024 (GMT+1)",
"30/03/2025 (GMT+2)",
"26/10/2025 (GMT+1)",
"29/03/2026 (GMT+2)",
"25/10/2026 (GMT+1)",
"28/03/2027 (GMT+2)",
"31/10/2027 (GMT+1)",
"26/03/2028 (GMT+2)",
"29/10/2028 (GMT+1)",
"25/03/2029 (GMT+2)",
"28/10/2029 (GMT+1)",
"31/03/2030 (GMT+2)",
"27/10/2030 (GMT+1)",
"30/03/2031 (GMT+2)",
"26/10/2031 (GMT+1)",
"28/03/2032 (GMT+2)",
"31/10/2032 (GMT+1)",
"27/03/2033 (GMT+2)",
"30/10/2033 (GMT+1)",
"26/03/2034 (GMT+2)",
"29/10/2034 (GMT+1)",
"25/03/2035 (GMT+2)",
"28/10/2035 (GMT+1)",
"30/03/2036 (GMT+2)",
"26/10/2036 (GMT+1)",
"29/03/2037 (GMT+2)",
"25/10/2037 (GMT+1)"
};
byte s, a, c, i = 0;
int y;
for(byte j = 0 ; j < sizeof(t)/(2 * sizeof(t[0])) ; j++)
{ y = 2000 + j;
s = (31 - (5 * y /4 + 4) % 7); // spring
c = DLST(y,3,s);
Serial.print(t[i++]); Serial.print(" Date: "); Serial.print(s); Serial.print("/03/"); Serial.print(y); Serial.print(" (GMT + ");Serial.print(1 + c);Serial.println(")");
a = (31 - (5 * y /4 + 1) % 7); // autumn
c = DLST(y,10,a);
Serial.print(t[i++]); Serial.print(" Date: "); Serial.print(a); Serial.print("/10/"); Serial.print(y); Serial.print(" (GMT + ");Serial.print(1 + c);Serial.println(")");
}
}
////////////////////////////////////////////////////////////////////////////////////////
void loop()
{ delay(1000);
}
////////////////////////////////////////////////////////////////////////////////////////
after I add this function (in 6 lnes) in my sketch using TinyGPS.
I use it each time I need display time and date on my tft screen (twice per second).
During waintig 3D fix location, I want display GSV signals in bargraph on my TFT sreen. If I loose some frame, it is not important.
After, just display local date and time, localisation, speed, altitude
With your librairy I discover an other univers about programming and I will rewrite/optimise my code with Oriented Object Programming.
Thank you very much for opening my mind.