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,6 +111,8 @@ namespace {
namespace ezt {
////////// Error handing ////////// Error handing
String errorString(const ezError_t err /* = LAST_ERROR */) { String errorString(const ezError_t err /* = LAST_ERROR */) {
@ -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
@ -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; }
@ -553,6 +555,7 @@ 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,7 +1470,7 @@ 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)); }
@ -1495,4 +1498,4 @@ uint8_t weekISO(time_t t /* = TIME_NOW */, const ezLocalOrUTC_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,19 +165,22 @@ typedef struct {
#define ISO8601_YWD "X-\\WW-N" #define ISO8601_YWD "X-\\WW-N"
#define DEFAULT_TIMEFORMAT COOKIE #define DEFAULT_TIMEFORMAT COOKIE
namespace ezt {
void breakTime(const time_t time, tmElements_t &tm); void breakTime(const time_t time, tmElements_t &tm);
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__);
String dayString(const uint8_t day); String dayShortStr(const uint8_t month);
String dayStr(const uint8_t month);
void deleteEvent(const uint8_t event_handle); void deleteEvent(const uint8_t event_handle);
void deleteEvent(void (*function)()); void deleteEvent(void (*function)());
ezError_t error(const bool reset = false); ezError_t error(const bool reset = false);
String errorString(const ezError_t err = LAST_ERROR); String errorString(const ezError_t err = LAST_ERROR);
void events(); void events();
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); 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);
time_t makeTime(tmElements_t &tm);
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);
time_t makeTime(tmElements_t &tm);
bool minuteChanged(); bool minuteChanged();
String monthString(const uint8_t month); String monthShortStr(const uint8_t month);
String monthStr(const uint8_t month);
bool secondChanged(); bool secondChanged();
void setDebug(const ezDebugLevel_t level); void setDebug(const ezDebugLevel_t level);
void setDebug(const ezDebugLevel_t level, Print &device); void setDebug(const ezDebugLevel_t level, Print &device);
@ -192,7 +195,7 @@ String zeropad(const uint32_t number, const uint8_t length);
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,7 +272,7 @@ 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 // These bounce through to same-named methods in defaultTZ
String dateTime(const String format = DEFAULT_TIMEFORMAT); String dateTime(const String format = DEFAULT_TIMEFORMAT);
String dateTime(time_t t, const String format = DEFAULT_TIMEFORMAT); String dateTime(time_t t, const String format = DEFAULT_TIMEFORMAT);
@ -297,6 +300,11 @@ uint8_t weekISO(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_T
uint8_t weekday(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 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); uint16_t yearISO(time_t t = TIME_NOW, const ezLocalOrUTC_t local_or_utc = LOCAL_TIME);
}
#ifndef EZTIME_EZT_NAMESPACE
using namespace ezt;
#endif
// 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