+bool ICACHE_FLASH_ATTR is_dst(struct tm *time)
+{
+ int lastsun = time->tm_mday - time->tm_wday;
+
+ if (time->tm_mon < 2 || time->tm_mon > 9)
+ return false;
+ if (time->tm_mon > 2 && time->tm_mon < 9)
+ return true;
+
+ /*
+ * Starts last Sunday in March, ends last Sunday in October, which must
+ * be at least the 25th of the month. So must be past that in March, or
+ * before that in October, to be in DST.
+ */
+ if (time->tm_mon == 2)
+ return (lastsun >= 25);
+ if (time->tm_mon == 9)
+ return (lastsun < 25);
+
+ return false;
+}
+
+/*
+ * Takes time, a Unix time (seconds since 1st Jan 1970) and breaks it down to:
+ *
+ * Time:
+ * tm_sec 0-59
+ * tm_min 0-59
+ * tm_hour 0-23
+ *
+ * Date:
+ * tm_year
+ * tm_mon 0-11
+ * tm_mday 1-31
+ *
+ * tm_yday
+ * tm_wday Sunday = 0, Saturday = 6
+ *
+ */