Some fixes to minuteChanged, ezt:: namespace, documentation fixes

pull/8/head 0.7.5
Rop 7 years ago
parent 417aed0119
commit 7603095917

@ -378,9 +378,9 @@ In the case of `SERVER_ERROR`, `errorString()` returns the error from the server
   
### Timezone caching, timezoneapi.io, EEPROM or NVS ### Timezone caching, EEPROM or NVS
If you use setLocation, the timezone information comes from timezoneapi.io, a service on the Internet that provides this information. They give everyone 50 free requests per day, so if your Arduino would get stuck in a loop where it boots all the time you would eventually not get timezone information anymore. Also, if that service goes away, your Arduino would not know what time it is anymore. If you use setLocation, the timezone information comes from timezoned.rop.nl. I'll try to keep that running as stable as possible, but if that service has a problem, your Arduino would not know what time it is anymore.
That is why you can create a place for ezTime to store the data about the timezone. That way, it doens't need to get the information anew every time the Arduino boots. You can store the cache for a timezone in EEPROM (the default) or NVS. That is why you can create a place for ezTime to store the data about the timezone. That way, it doens't need to get the information anew every time the Arduino boots. You can store the cache for a timezone in EEPROM (the default) or NVS.
@ -422,7 +422,7 @@ The Chatham Islands are in Pacific about 800 kilometres east of New Zealand. Som
#### Morocco #### Morocco
Morocco goes on and off Daylight Saving Time twice per year. This currently breaks ezTime as timezoneapi.io gives us a posix string that only contains the first of the periods. Fortunately they will stop doing this in 2020: the Moroccans probably got tired of all the clocks that did not adjust properly. Morocco goes on and off Daylight Saving Time twice per year. This currently breaks ezTime as our parser can only handle one DST period per year. Fortunately they will stop doing this in 2020: the Moroccans probably got tired of all the clocks that did not adjust properly.
   
@ -535,7 +535,7 @@ These will tell if it is before or after noon for a given `TIME`, return `true`
   
`uint16_t dayOfYear(TIME)`    — Both assume default timezone if no timezone is prefixed `uint16_t dayOfYear(TIME)`    — Assumes default timezone if no timezone is prefixed
Returns how many days have passed in the year. January 1st returns 0, Returns how many days have passed in the year. January 1st returns 0,
@ -835,7 +835,7 @@ Global variables use 733 bytes (35%) of dynamic memory, leaving 1315 bytes for l
By setting `#define EZTIME_MAX_DEBUGLEVEL_NONE` in `eztime.h` we can free up some more flash: By setting `#define EZTIME_MAX_DEBUGLEVEL_NONE` in `eztime.h` we can free up some more flash:
``` ```
ketch uses 23870 bytes (74%) of program storage space. Maximum is 32256 bytes. Sketch uses 23870 bytes (74%) of program storage space. Maximum is 32256 bytes.
Global variables use 729 bytes (35%) of dynamic memory, leaving 1319 bytes for local variables. Maximum is 2048 bytes. Global variables use 729 bytes (35%) of dynamic memory, leaving 1319 bytes for local variables. Maximum is 2048 bytes.
``` ```
@ -936,7 +936,7 @@ ezTime 0.7.2 runs fine (No networking on board, so tested with NoNetwork example
* [getTimezoneName](#gettimezonename) * [getTimezoneName](#gettimezonename)
* [getOffset](#getoffset) * [getOffset](#getoffset)
* [setLocation](#setlocation) * [setLocation](#setlocation)
* [Timezone caching, timezoneapi.io, EEPROM or NVS](#timezone-caching-timezoneapiio-eeprom-or-nvs) * [Timezone caching, EEPROM or NVS](#timezone-caching-eeprom-or-nvs)
* [setCache](#setcache) * [setCache](#setcache)
* [clearCache](#clearcache) * [clearCache](#clearcache)
* [Crazy timezones](#crazy-timezones) * [Crazy timezones](#crazy-timezones)

@ -11,7 +11,7 @@
"type": "git", "type": "git",
"url": "https://github.com/ropg/ezTime" "url": "https://github.com/ropg/ezTime"
}, },
"version": "0.7.4", "version": "0.7.5",
"framework": "arduino", "framework": "arduino",
"platforms": "*", "platforms": "*",
"build": { "build": {

@ -1,5 +1,5 @@
name=ezTime name=ezTime
version=0.7.4 version=0.7.5
author=Rop Gonggrijp author=Rop Gonggrijp
maintainer=Rop Gonggrijp maintainer=Rop Gonggrijp
sentence=ezTime - pronounced "Easy Time" - is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more. sentence=ezTime - pronounced "Easy Time" - is a very easy to use Arduino time and date library that provides NTP network time lookups, extensive timezone support, formatted time and date strings, user events, millisecond precision and more.

@ -83,7 +83,7 @@ namespace {
_last_error = err; _last_error = err;
if (_last_error) { if (_last_error) {
err(F("ERROR: ")); err(F("ERROR: "));
errln(errorString(err)); errln(ezt::errorString(err));
} }
} }
@ -111,9 +111,11 @@ namespace {
////////// Error handing namespace ezt {
String errorString(const ezError_t err /* = LAST_ERROR */) { ////////// Error handing
String errorString(const ezError_t err /* = LAST_ERROR */) {
switch (err) { switch (err) {
case NO_ERROR: return F("OK"); case NO_ERROR: return F("OK");
case LAST_ERROR: return errorString(_last_error); case LAST_ERROR: return errorString(_last_error);
@ -128,30 +130,30 @@ String errorString(const ezError_t err /* = LAST_ERROR */) {
case SERVER_ERROR: return _server_error; case SERVER_ERROR: return _server_error;
default: return F("Unkown error"); default: return F("Unkown error");
} }
} }
ezError_t error(const bool reset /* = false */) { ezError_t error(const bool reset /* = false */) {
ezError_t tmp = _last_error; ezError_t tmp = _last_error;
if (reset) _last_error = NO_ERROR; if (reset) _last_error = NO_ERROR;
return tmp; return tmp;
} }
void setDebug(const ezDebugLevel_t level) { void setDebug(const ezDebugLevel_t level) {
setDebug(level, *_debug_device); setDebug(level, *_debug_device);
} }
void setDebug(const ezDebugLevel_t level, Print &device) { void setDebug(const ezDebugLevel_t level, Print &device) {
_debug_level = level; _debug_level = level;
_debug_device = &device; _debug_device = &device;
info(F("\r\nezTime debug level set to ")); info(F("\r\nezTime debug level set to "));
infoln(debugLevelString(level)); infoln(debugLevelString(level));
} }
//////////////////////// ////////////////////////
String monthStr(const uint8_t month) { String monthStr(const uint8_t month) {
switch(month) { switch(month) {
case 1: return F("January"); case 1: return F("January");
case 2: return F("February"); case 2: return F("February");
@ -167,9 +169,9 @@ String monthStr(const uint8_t month) {
case 12: return F("December"); case 12: return F("December");
} }
return ""; return "";
} }
String dayStr(const uint8_t day) { String dayStr(const uint8_t day) {
switch(day) { switch(day) {
case 1: return F("Sunday"); case 1: return F("Sunday");
case 2: return F("Monday"); case 2: return F("Monday");
@ -180,16 +182,16 @@ String dayStr(const uint8_t day) {
case 7: return F("Saturday"); case 7: return F("Saturday");
} }
return ""; return "";
} }
// Original time lib compatibility // Original time lib compatibility
String dayShortStr(const uint8_t day) { return dayStr(day).substring(0,3); } String dayShortStr(const uint8_t day) { return dayStr(day).substring(0,3); }
String monthShortStr(const uint8_t month) { return monthStr(month).substring(0,3); } String monthShortStr(const uint8_t month) { return monthStr(month).substring(0,3); }
timeStatus_t timeStatus() { return _time_status; } timeStatus_t timeStatus() { return _time_status; }
void events() { void events() {
if (!_initialised) { if (!_initialised) {
for (uint8_t n = 0; n < MAX_EVENTS; n++) _events[n] = { 0, NULL }; for (uint8_t n = 0; n < MAX_EVENTS; n++) _events[n] = { 0, NULL };
#ifdef EZTIME_NETWORK_ENABLE #ifdef EZTIME_NETWORK_ENABLE
@ -199,7 +201,7 @@ void events() {
} }
// See if any events are due // See if any events are due
for (uint8_t n = 0; n < MAX_EVENTS; n++) { for (uint8_t n = 0; n < MAX_EVENTS; n++) {
if (_events[n].function && nowUTC() >= _events[n].time) { if (_events[n].function && nowUTC(false) >= _events[n].time) {
debug(F("Running event (#")); debug(n + 1); debug(F(") set for ")); debugln(UTC.dateTime(_events[n].time)); debug(F("Running event (#")); debug(n + 1); debug(F(") set for ")); debugln(UTC.dateTime(_events[n].time));
void (*tmp)() = _events[n].function; void (*tmp)() = _events[n].function;
_events[n] = { 0, NULL }; // reset the event _events[n] = { 0, NULL }; // reset the event
@ -207,25 +209,25 @@ void events() {
} }
} }
yield(); yield();
} }
void deleteEvent(const uint8_t event_handle) { void deleteEvent(const uint8_t event_handle) {
if (event_handle && event_handle <= MAX_EVENTS) { if (event_handle && event_handle <= MAX_EVENTS) {
debug(F("Deleted event (#")); debug(event_handle); debug(F("), set for ")); debugln(UTC.dateTime(_events[event_handle - 1].time)); debug(F("Deleted event (#")); debug(event_handle); debug(F("), set for ")); debugln(UTC.dateTime(_events[event_handle - 1].time));
_events[event_handle - 1] = { 0, NULL }; _events[event_handle - 1] = { 0, NULL };
} }
} }
void deleteEvent(void (*function)()) { void deleteEvent(void (*function)()) {
for (uint8_t n = 0; n< MAX_EVENTS; n++) { for (uint8_t n = 0; n< MAX_EVENTS; n++) {
if (_events[n].function == function) { if (_events[n].function == function) {
debug(F("Deleted event (#")); debug(n + 1); debug(F("), set for ")); debugln(UTC.dateTime(_events[n].time)); debug(F("Deleted event (#")); debug(n + 1); debug(F("), set for ")); debugln(UTC.dateTime(_events[n].time));
_events[n] = { 0, NULL }; _events[n] = { 0, NULL };
} }
} }
} }
void breakTime(const time_t timeInput, tmElements_t &tm){ void breakTime(const time_t timeInput, tmElements_t &tm){
// break the given time_t into time components // break the given time_t into time components
// this is a more compact version of the C library localtime function // this is a more compact version of the C library localtime function
// note that year is offset from 1970 !!! // note that year is offset from 1970 !!!
@ -276,9 +278,9 @@ void breakTime(const time_t timeInput, tmElements_t &tm){
} }
tm.Month = month + 1; // jan is month 1 tm.Month = month + 1; // jan is month 1
tm.Day = time + 1; // day of month tm.Day = time + 1; // day of month
} }
time_t makeTime(const uint8_t hour, const uint8_t minute, const uint8_t second, const uint8_t day, const uint8_t month, const uint16_t year) { time_t makeTime(const uint8_t hour, const uint8_t minute, const uint8_t second, const uint8_t day, const uint8_t month, const uint16_t year) {
tmElements_t tm; tmElements_t tm;
tm.Hour = hour; tm.Hour = hour;
tm.Minute = minute; tm.Minute = minute;
@ -291,12 +293,12 @@ time_t makeTime(const uint8_t hour, const uint8_t minute, const uint8_t second,
tm.Year = year; tm.Year = year;
} }
return makeTime(tm); return makeTime(tm);
} }
time_t makeTime(tmElements_t &tm){ time_t makeTime(tmElements_t &tm){
// assemble time elements into time_t // assemble time elements into time_t
// note year argument is offset from 1970 (see macros in time.h to convert to other formats) // note year argument is offset from 1970 (see macros in time.h to convert to other formats)
// previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9 // previous version used full four digit year (or digits since 2000),i.e. 2009 was 2009 or 9
int i; int i;
uint32_t seconds; uint32_t seconds;
@ -325,12 +327,12 @@ time_t makeTime(tmElements_t &tm){
seconds+= tm.Second; seconds+= tm.Second;
return (time_t)seconds; return (time_t)seconds;
} }
// makeOrdinalTime allows you to resolve "second thursday in September in 2018" into a number of seconds since 1970 // makeOrdinalTime allows you to resolve "second thursday in September in 2018" into a number of seconds since 1970
// (Very useful for the timezone calculations that ezTime does internally) // (Very useful for the timezone calculations that ezTime does internally)
// If ordinal is 0 or 5 it is taken to mean "the last $wday in $month" // If ordinal is 0 or 5 it is taken to mean "the last $wday in $month"
time_t makeOrdinalTime(const uint8_t hour, const uint8_t minute, uint8_t const second, uint8_t ordinal, const uint8_t wday, const uint8_t month, uint16_t year) { time_t makeOrdinalTime(const uint8_t hour, const uint8_t minute, uint8_t const second, uint8_t ordinal, const uint8_t wday, const uint8_t month, uint16_t year) {
if (year <= 68 ) year = 1970 + year; // fix user intent if (year <= 68 ) year = 1970 + year; // fix user intent
uint8_t m = month; uint8_t m = month;
uint8_t w = ordinal; uint8_t w = ordinal;
@ -348,9 +350,9 @@ time_t makeOrdinalTime(const uint8_t hour, const uint8_t minute, uint8_t const s
// back up a week if this is a "Last" rule // back up a week if this is a "Last" rule
if (ordinal == 0) t -= 7 * SECS_PER_DAY; if (ordinal == 0) t -= 7 * SECS_PER_DAY;
return t; return t;
} }
String urlEncode(const String str) { String urlEncode(const String str) {
String encodedString=""; String encodedString="";
char c; char c;
char code0; char code0;
@ -377,17 +379,17 @@ String urlEncode(const String str) {
} }
} }
return encodedString; return encodedString;
} }
String zeropad(const uint32_t number, const uint8_t length) { String zeropad(const uint32_t number, const uint8_t length) {
String out; String out;
out.reserve(length); out.reserve(length);
out = String(number); out = String(number);
while (out.length() < length) out = "0" + out; while (out.length() < length) out = "0" + out;
return out; return out;
} }
time_t compileTime(const String compile_date /* = __DATE__ */, const String compile_time /* = __TIME__ */) { time_t compileTime(const String compile_date /* = __DATE__ */, const String compile_time /* = __TIME__ */) {
uint8_t hrs = compile_time.substring(0,2).toInt(); uint8_t hrs = compile_time.substring(0,2).toInt();
uint8_t min = compile_time.substring(3,5).toInt(); uint8_t min = compile_time.substring(3,5).toInt();
@ -402,22 +404,22 @@ time_t compileTime(const String compile_date /* = __DATE__ */, const String comp
} }
} }
return 0; return 0;
} }
bool secondChanged() { bool secondChanged() {
time_t t = nowUTC(false); time_t t = nowUTC(false);
if (_last_read_t != t) return true; if (_last_read_t != t) return true;
return false; return false;
} }
bool minuteChanged() { bool minuteChanged() {
time_t t = nowUTC(false); time_t t = nowUTC(false);
if (_last_read_t / 60 != t / 60) return true; if (_last_read_t / 60 != t / 60) return true;
return false; return false;
} }
#ifdef EZTIME_NETWORK_ENABLE #ifdef EZTIME_NETWORK_ENABLE
void updateNTP() { void updateNTP() {
deleteEvent(updateNTP); // Delete any events pointing here, in case called manually deleteEvent(updateNTP); // Delete any events pointing here, in case called manually
@ -448,7 +450,7 @@ bool minuteChanged() {
if (_ntp_interval) UTC.setEvent(updateNTP, t + _ntp_interval); if (_ntp_interval) UTC.setEvent(updateNTP, t + _ntp_interval);
_time_status = timeSet; _time_status = timeSet;
} else { } else {
UTC.setEvent(updateNTP, nowUTC() + NTP_RETRY); UTC.setEvent(updateNTP, nowUTC(false) + NTP_RETRY);
} }
} }
@ -518,7 +520,7 @@ bool minuteChanged() {
void setInterval(const uint16_t seconds /* = 0 */) { void setInterval(const uint16_t seconds /* = 0 */) {
deleteEvent(updateNTP); deleteEvent(updateNTP);
_ntp_interval = seconds; _ntp_interval = seconds;
if (seconds) UTC.setEvent(updateNTP, nowUTC() + _ntp_interval); if (seconds) UTC.setEvent(updateNTP, nowUTC(false) + _ntp_interval);
} }
void setServer(const String ntp_server /* = NTP_SERVER */) { _ntp_server = ntp_server; } void setServer(const String ntp_server /* = NTP_SERVER */) { _ntp_server = ntp_server; }
@ -551,8 +553,9 @@ bool minuteChanged() {
} }
#endif // EZTIME_NETWORK_ENABLE #endif // EZTIME_NETWORK_ENABLE
}
// //
@ -764,11 +767,11 @@ time_t Timezone::tzTime(time_t t, ezLocalOrUTC_t local_or_utc, String &tzname, b
int16_t dst_offset = std_offset - dst_shift_hr * 60 - dst_shift_min; int16_t dst_offset = std_offset - dst_shift_hr * 60 - dst_shift_min;
// to find the year // to find the year
tmElements_t tm; tmElements_t tm;
breakTime(t, tm); ezt::breakTime(t, tm);
// in local time // in local time
time_t dst_start = makeOrdinalTime(start_time_hr, start_time_min, 0, start_week, start_dow, start_month, tm.Year + 1970); time_t dst_start = ezt::makeOrdinalTime(start_time_hr, start_time_min, 0, start_week, start_dow, start_month, tm.Year + 1970);
time_t dst_end = makeOrdinalTime(end_time_hr, end_time_min, 0, end_week, end_dow, end_month, tm.Year + 1970); time_t dst_end = ezt::makeOrdinalTime(end_time_hr, end_time_min, 0, end_week, end_dow, end_month, tm.Year + 1970);
if (local_or_utc == UTC_TIME) { if (local_or_utc == UTC_TIME) {
dst_start -= std_offset; dst_start -= std_offset;
@ -1133,7 +1136,7 @@ int16_t Timezone::getOffset(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local
} }
uint8_t Timezone::setEvent(void (*function)(), const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t mnth, uint16_t yr) { uint8_t Timezone::setEvent(void (*function)(), const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t mnth, uint16_t yr) {
time_t t = makeTime(hr, min, sec, day, mnth, yr); time_t t = ezt::makeTime(hr, min, sec, day, mnth, yr);
return setEvent(function, t); return setEvent(function, t);
} }
@ -1174,7 +1177,7 @@ void Timezone::setTime(const uint8_t hr, const uint8_t min, const uint8_t sec, c
tm.Hour = hr; tm.Hour = hr;
tm.Minute = min; tm.Minute = min;
tm.Second = sec; tm.Second = sec;
setTime(makeTime(tm)); setTime(ezt::makeTime(tm));
} }
String Timezone::dateTime(const String format /* = DEFAULT_TIMEFORMAT */) { String Timezone::dateTime(const String format /* = DEFAULT_TIMEFORMAT */) {
@ -1197,7 +1200,7 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
String out = ""; String out = "";
tmElements_t tm; tmElements_t tm;
breakTime(t, tm); ezt::breakTime(t, tm);
int8_t hour12 = tm.Hour % 12; int8_t hour12 = tm.Hour % 12;
if (hour12 == 0) hour12 = 12; if (hour12 == 0) hour12 = 12;
@ -1222,16 +1225,16 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
escape_char = true; escape_char = true;
break; break;
case 'd': // Day of the month, 2 digits with leading zeros case 'd': // Day of the month, 2 digits with leading zeros
out += zeropad(tm.Day, 2); out += ezt::zeropad(tm.Day, 2);
break; break;
case 'D': // A textual representation of a day, three letters case 'D': // A textual representation of a day, three letters
out += dayStr(tm.Wday).substring(0,3); out += ezt::dayStr(tm.Wday).substring(0,3);
break; break;
case 'j': // Day of the month without leading zeros case 'j': // Day of the month without leading zeros
out += String(tm.Day); out += String(tm.Day);
break; break;
case 'l': // (lowercase L) A full textual representation of the day of the week case 'l': // (lowercase L) A full textual representation of the day of the week
out += dayStr(tm.Wday); out += ezt::dayStr(tm.Wday);
break; break;
case 'N': // ISO-8601 numeric representation of the day of the week. ( 1 = Monday, 7 = Sunday ) case 'N': // ISO-8601 numeric representation of the day of the week. ( 1 = Monday, 7 = Sunday )
tmpint8 = tm.Wday - 1; tmpint8 = tm.Wday - 1;
@ -1258,13 +1261,13 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
out += String(tm.Wday); out += String(tm.Wday);
break; break;
case 'F': // A full textual representation of a month, such as January or March case 'F': // A full textual representation of a month, such as January or March
out += monthStr(tm.Month); out += ezt::monthStr(tm.Month);
break; break;
case 'm': // Numeric representation of a month, with leading zeros case 'm': // Numeric representation of a month, with leading zeros
out += zeropad(tm.Month, 2); out += ezt::zeropad(tm.Month, 2);
break; break;
case 'M': // A short textual representation of a month, three letters case 'M': // A short textual representation of a month, three letters
out += monthStr(tm.Month).substring(0,3); out += ezt::monthStr(tm.Month).substring(0,3);
break; break;
case 'n': // Numeric representation of a month, without leading zeros case 'n': // Numeric representation of a month, without leading zeros
out += String(tm.Month); out += String(tm.Month);
@ -1276,7 +1279,7 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
out += String(tm.Year + 1970); out += String(tm.Year + 1970);
break; break;
case 'y': // A two digit representation of a year case 'y': // A two digit representation of a year
out += zeropad((tm.Year + 1970) % 100, 2); out += ezt::zeropad((tm.Year + 1970) % 100, 2);
break; break;
case 'a': // am or pm case 'a': // am or pm
out += (tm.Hour < 12) ? F("am") : F("pm"); out += (tm.Hour < 12) ? F("am") : F("pm");
@ -1291,22 +1294,22 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
out += String(tm.Hour); out += String(tm.Hour);
break; break;
case 'h': // 12-hour format of an hour with leading zeros case 'h': // 12-hour format of an hour with leading zeros
out += zeropad(hour12, 2); out += ezt::zeropad(hour12, 2);
break; break;
case 'H': // 24-hour format of an hour with leading zeros case 'H': // 24-hour format of an hour with leading zeros
out += zeropad(tm.Hour, 2); out += ezt::zeropad(tm.Hour, 2);
break; break;
case 'i': // Minutes with leading zeros case 'i': // Minutes with leading zeros
out += zeropad(tm.Minute, 2); out += ezt::zeropad(tm.Minute, 2);
break; break;
case 's': // Seconds with leading zeros case 's': // Seconds with leading zeros
out += zeropad(tm.Second, 2); out += ezt::zeropad(tm.Second, 2);
break; break;
case 'T': // abbreviation for timezone case 'T': // abbreviation for timezone
out += tzname; out += tzname;
break; break;
case 'v': // milliseconds as three digits case 'v': // milliseconds as three digits
out += zeropad(_last_read_ms, 3); out += ezt::zeropad(_last_read_ms, 3);
break; break;
#ifdef EZTIME_NETWORK_ENABLE #ifdef EZTIME_NETWORK_ENABLE
case 'e': // Timezone identifier (Olsen) case 'e': // Timezone identifier (Olsen)
@ -1318,9 +1321,9 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
o = offset; o = offset;
out += (o < 0) ? "+" : "-"; // reversed from our offset out += (o < 0) ? "+" : "-"; // reversed from our offset
if (o < 0) o = 0 - o; if (o < 0) o = 0 - o;
out += zeropad(o / 60, 2); out += ezt::zeropad(o / 60, 2);
out += (c == 'P') ? ":" : ""; out += (c == 'P') ? ":" : "";
out += zeropad(o % 60, 2); out += ezt::zeropad(o % 60, 2);
break; break;
case 'Z': //Timezone offset in seconds. West of UTC is negative, east of UTC is positive. case 'Z': //Timezone offset in seconds. West of UTC is negative, east of UTC is positive.
out += String(0 - offset * 60); out += String(0 - offset * 60);
@ -1329,7 +1332,7 @@ String Timezone::dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const Str
out += String(dayOfYear(t)); // The day of the year (starting from 0) out += String(dayOfYear(t)); // The day of the year (starting from 0)
break; break;
case 'W': case 'W':
out += zeropad(weekISO(t), 2); // ISO-8601 week number of year, weeks starting on Monday out += ezt::zeropad(weekISO(t), 2); // ISO-8601 week number of year, weeks starting on Monday
break; break;
case 'X': case 'X':
out += String(yearISO(t)); // ISO-8601 year-week notation year, see https://en.wikipedia.org/wiki/ISO_week_date out += String(yearISO(t)); // ISO-8601 year-week notation year, see https://en.wikipedia.org/wiki/ISO_week_date
@ -1384,34 +1387,34 @@ uint16_t Timezone::ms(time_t t /*= TIME_NOW */) {
uint8_t Timezone::day(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { uint8_t Timezone::day(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) {
t = tzTime(t, local_or_utc); t = tzTime(t, local_or_utc);
tmElements_t tm; tmElements_t tm;
breakTime(t, tm); ezt::breakTime(t, tm);
return tm.Day; return tm.Day;
} }
uint8_t Timezone::weekday(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { uint8_t Timezone::weekday(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) {
t = tzTime(t, local_or_utc); t = tzTime(t, local_or_utc);
tmElements_t tm; tmElements_t tm;
breakTime(t, tm); ezt::breakTime(t, tm);
return tm.Wday; return tm.Wday;
} }
uint8_t Timezone::month(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { uint8_t Timezone::month(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) {
t = tzTime(t, local_or_utc); t = tzTime(t, local_or_utc);
tmElements_t tm; tmElements_t tm;
breakTime(t, tm); ezt::breakTime(t, tm);
return tm.Month; return tm.Month;
} }
uint16_t Timezone::year(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { uint16_t Timezone::year(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) {
t = tzTime(t, local_or_utc); t = tzTime(t, local_or_utc);
tmElements_t tm; tmElements_t tm;
breakTime(t, tm); ezt::breakTime(t, tm);
return tm.Year + 1970; return tm.Year + 1970;
} }
uint16_t Timezone::dayOfYear(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { uint16_t Timezone::dayOfYear(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) {
t = tzTime(t, local_or_utc); t = tzTime(t, local_or_utc);
time_t jan_1st = makeTime(0, 0, 0, 1, 1, year(t)); time_t jan_1st = ezt::makeTime(0, 0, 0, 1, 1, year(t));
return (t - jan_1st) / SECS_PER_DAY; return (t - jan_1st) / SECS_PER_DAY;
} }
@ -1441,7 +1444,7 @@ bool Timezone::isPM(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc
// definition for week 01 is the week with the Gregorian year's first Thursday in it. // definition for week 01 is the week with the Gregorian year's first Thursday in it.
// See https://en.wikipedia.org/wiki/ISO_week_date // See https://en.wikipedia.org/wiki/ISO_week_date
// //
#define startISOyear(year...) makeOrdinalTime(0, 0, 0, FIRST, THURSDAY, JANUARY, year) - 3UL * SECS_PER_DAY; #define startISOyear(year...) ezt::makeOrdinalTime(0, 0, 0, FIRST, THURSDAY, JANUARY, year) - 3UL * SECS_PER_DAY;
uint8_t Timezone::weekISO(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { uint8_t Timezone::weekISO(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) {
t = tzTime(t, local_or_utc); t = tzTime(t, local_or_utc);
int16_t yr = year(t); int16_t yr = year(t);
@ -1467,32 +1470,32 @@ uint16_t Timezone::yearISO(time_t t /*= TIME_NOW */, const ezLocalOrUTC_t local_
Timezone UTC; Timezone UTC;
Timezone *defaultTZ = &UTC; Timezone *defaultTZ = &UTC;
namespace ezt {
// All bounce-throughs to defaultTZ // All bounce-throughs to defaultTZ
String dateTime(const String format /* = DEFAULT_TIMEFORMAT */) { return (defaultTZ->dateTime(format)); } String dateTime(const String format /* = DEFAULT_TIMEFORMAT */) { return (defaultTZ->dateTime(format)); }
String dateTime(time_t t, const String format /* = DEFAULT_TIMEFORMAT */) { return (defaultTZ->dateTime(t, format)); } String dateTime(time_t t, const String format /* = DEFAULT_TIMEFORMAT */) { return (defaultTZ->dateTime(t, format)); }
String dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const String format /* = DEFAULT_TIMEFORMAT */) { return (defaultTZ->dateTime(t, local_or_utc, format)); } String dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const String format /* = DEFAULT_TIMEFORMAT */) { return (defaultTZ->dateTime(t, local_or_utc, format)); }
uint8_t day(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->day(t, local_or_utc)); } uint8_t day(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->day(t, local_or_utc)); }
uint16_t dayOfYear(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->dayOfYear(t, local_or_utc)); } uint16_t dayOfYear(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->dayOfYear(t, local_or_utc)); }
int16_t getOffset(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->getOffset(t, local_or_utc)); } int16_t getOffset(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->getOffset(t, local_or_utc)); }
String getTimezoneName(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->getTimezoneName(t, local_or_utc)); } String getTimezoneName(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->getTimezoneName(t, local_or_utc)); }
uint8_t hour(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->hour(t, local_or_utc)); } uint8_t hour(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->hour(t, local_or_utc)); }
uint8_t hourFormat12(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->hourFormat12(t, local_or_utc)); } uint8_t hourFormat12(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->hourFormat12(t, local_or_utc)); }
bool isAM(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->isAM(t, local_or_utc)); } bool isAM(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->isAM(t, local_or_utc)); }
bool isDST(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->isDST(t, local_or_utc)); } bool isDST(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->isDST(t, local_or_utc)); }
bool isPM(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->isPM(t, local_or_utc)); } bool isPM(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->isPM(t, local_or_utc)); }
String militaryTZ(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->militaryTZ(t, local_or_utc)); } String militaryTZ(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->militaryTZ(t, local_or_utc)); }
uint8_t minute(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->minute(t, local_or_utc)); } uint8_t minute(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->minute(t, local_or_utc)); }
uint8_t month(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->month(t, local_or_utc)); } uint8_t month(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->month(t, local_or_utc)); }
uint16_t ms(time_t t /* = TIME_NOW */) { return (defaultTZ->ms(t)); } uint16_t ms(time_t t /* = TIME_NOW */) { return (defaultTZ->ms(t)); }
time_t now() { return (defaultTZ->now()); } time_t now() { return (defaultTZ->now()); }
uint8_t second(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->second(t, local_or_utc)); } uint8_t second(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->second(t, local_or_utc)); }
uint8_t setEvent(void (*function)(), const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t mnth, uint16_t yr) { return (defaultTZ->setEvent(function,hr, min, sec, day, mnth, yr)); } uint8_t setEvent(void (*function)(), const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t mnth, uint16_t yr) { return (defaultTZ->setEvent(function,hr, min, sec, day, mnth, yr)); }
uint8_t setEvent(void (*function)(), time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->setEvent(function, t, local_or_utc)); } uint8_t setEvent(void (*function)(), time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->setEvent(function, t, local_or_utc)); }
void setTime(const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t month, const uint16_t yr) { defaultTZ->setTime(hr, min, sec, day, month, yr); } void setTime(const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t month, const uint16_t yr) { defaultTZ->setTime(hr, min, sec, day, month, yr); }
void setTime(time_t t) { defaultTZ->setTime(t); } void setTime(time_t t) { defaultTZ->setTime(t); }
uint8_t weekISO(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->weekISO(t, local_or_utc)); } uint8_t weekISO(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->weekISO(t, local_or_utc)); }
uint8_t weekday(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->weekday(t, local_or_utc)); } uint8_t weekday(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->weekday(t, local_or_utc)); }
uint16_t year(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->year(t, local_or_utc)); } uint16_t year(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->year(t, local_or_utc)); }
uint16_t yearISO(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->yearISO(t, local_or_utc)); } uint16_t yearISO(time_t t /* = TIME_NOW */, const ezLocalOrUTC_t local_or_utc /* = LOCAL_TIME */) { return (defaultTZ->yearISO(t, local_or_utc)); }
}

@ -165,34 +165,37 @@ typedef struct {
#define ISO8601_YWD "X-\\WW-N" #define ISO8601_YWD "X-\\WW-N"
#define DEFAULT_TIMEFORMAT COOKIE #define DEFAULT_TIMEFORMAT COOKIE
void breakTime(const time_t time, tmElements_t &tm); namespace ezt {
time_t compileTime(const String compile_date = __DATE__, const String compile_time = __TIME__); void breakTime(const time_t time, tmElements_t &tm);
String dayString(const uint8_t day); time_t compileTime(const String compile_date = __DATE__, const String compile_time = __TIME__);
void deleteEvent(const uint8_t event_handle); String dayShortStr(const uint8_t month);
void deleteEvent(void (*function)()); String dayStr(const uint8_t month);
ezError_t error(const bool reset = false); void deleteEvent(const uint8_t event_handle);
String errorString(const ezError_t err = LAST_ERROR); void deleteEvent(void (*function)());
void events(); ezError_t error(const bool reset = false);
time_t makeOrdinalTime(const uint8_t hour, const uint8_t minute, const uint8_t second, uint8_t ordinal, const uint8_t wday, const uint8_t month, uint16_t year); String errorString(const ezError_t err = LAST_ERROR);
time_t makeTime(tmElements_t &tm); void events();
time_t makeTime(const uint8_t hour, const uint8_t minute, const uint8_t second, const uint8_t day, const uint8_t month, const uint16_t year); time_t makeOrdinalTime(const uint8_t hour, const uint8_t minute, const uint8_t second, uint8_t ordinal, const uint8_t wday, const uint8_t month, uint16_t year);
bool minuteChanged(); time_t makeTime(const uint8_t hour, const uint8_t minute, const uint8_t second, const uint8_t day, const uint8_t month, const uint16_t year);
String monthString(const uint8_t month); time_t makeTime(tmElements_t &tm);
bool secondChanged(); bool minuteChanged();
void setDebug(const ezDebugLevel_t level); String monthShortStr(const uint8_t month);
void setDebug(const ezDebugLevel_t level, Print &device); String monthStr(const uint8_t month);
timeStatus_t timeStatus(); bool secondChanged();
String urlEncode(const String str); void setDebug(const ezDebugLevel_t level);
String zeropad(const uint32_t number, const uint8_t length); void setDebug(const ezDebugLevel_t level, Print &device);
timeStatus_t timeStatus();
#ifdef EZTIME_NETWORK_ENABLE String urlEncode(const String str);
String zeropad(const uint32_t number, const uint8_t length);
#ifdef EZTIME_NETWORK_ENABLE
bool queryNTP(const String server, time_t &t, unsigned long &measured_at); bool queryNTP(const String server, time_t &t, unsigned long &measured_at);
void setInterval(const uint16_t seconds = 0); void setInterval(const uint16_t seconds = 0);
void setServer(const String ntp_server = NTP_SERVER); void setServer(const String ntp_server = NTP_SERVER);
void updateNTP(); void updateNTP();
bool waitForSync(const uint16_t timeout = 0); bool waitForSync(const uint16_t timeout = 0);
#endif #endif
}
// //
// T i m e z o n e c l a s s // T i m e z o n e c l a s s
@ -269,34 +272,39 @@ class Timezone {
extern Timezone UTC; extern Timezone UTC;
extern Timezone *defaultTZ; extern Timezone *defaultTZ;
namespace ezt {
// These bounce through to same-named methods in defaultTZ
String dateTime(const String format = DEFAULT_TIMEFORMAT);
String dateTime(time_t t, const String format = DEFAULT_TIMEFORMAT);
String dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const String format = DEFAULT_TIMEFORMAT);
uint8_t day(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t dayOfYear(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
int16_t getOffset(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
String getTimezoneName(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t hour(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t hourFormat12(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
bool isAM(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
bool isDST(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
bool isPM(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
String militaryTZ(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t minute(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t month(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t ms(time_t t = TIME_NOW);
time_t now();
uint8_t second(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t setEvent(void (*function)(), const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t mnth, uint16_t yr);
uint8_t setEvent(void (*function)(), time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
void setTime(const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t month, const uint16_t yr);
void setTime(time_t t);
uint8_t weekISO(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t weekday(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t year(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t yearISO(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
}
// These bounce through to same-named methods in defaultTZ #ifndef EZTIME_EZT_NAMESPACE
String dateTime(const String format = DEFAULT_TIMEFORMAT); using namespace ezt;
String dateTime(time_t t, const String format = DEFAULT_TIMEFORMAT); #endif
String dateTime(time_t t, const ezLocalOrUTC_t local_or_utc, const String format = DEFAULT_TIMEFORMAT);
uint8_t day(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t dayOfYear(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
int16_t getOffset(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
String getTimezoneName(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t hour(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t hourFormat12(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
bool isAM(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
bool isDST(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
bool isPM(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
String militaryTZ(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t minute(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t month(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t ms(time_t t = TIME_NOW);
time_t now();
uint8_t second(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t setEvent(void (*function)(), const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t mnth, uint16_t yr);
uint8_t setEvent(void (*function)(), time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
void setTime(const uint8_t hr, const uint8_t min, const uint8_t sec, const uint8_t day, const uint8_t month, const uint16_t yr);
void setTime(time_t t);
uint8_t weekISO(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint8_t weekday(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t year(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
uint16_t yearISO(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
// The following defines all copied from the original Time lib to keep existing code working // The following defines all copied from the original Time lib to keep existing code working
@ -331,12 +339,6 @@ uint16_t yearISO(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_
#define daysToTime_t ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011 #define daysToTime_t ((D)) ( (D) * SECS_PER_DAY) // fixed on Jul 22 2011
#define weeksToTime_t ((W)) ( (W) * SECS_PER_WEEK) #define weeksToTime_t ((W)) ( (W) * SECS_PER_WEEK)
// Aliases to match original Time library
String monthStr(const uint8_t month);
String monthShortStr(const uint8_t month);
String dayStr(const uint8_t month);
String dayShortStr(const uint8_t month);
} // extern "C++" } // extern "C++"
#endif // __cplusplus #endif // __cplusplus

Loading…
Cancel
Save