Skip to content

Commit

Permalink
BIG: changed API, documentation, lots of testing, fixes, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
ropg committed Sep 12, 2018
1 parent 7631760 commit c1f0778
Show file tree
Hide file tree
Showing 17 changed files with 770 additions and 595 deletions.
393 changes: 265 additions & 128 deletions README.md

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions examples/EventsAndOrdinalTime/EventsAndOrdinalTime.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@
void setup() {

Serial.begin(115200);
while (!Serial) { ; } // wait for Serial port to connect. Needed for native USB port only
WiFi.begin("your-ssid", "your-password");

time.waitForSync();
waitForSync();

// Set the event to trigger for the first time
UTC.setEvent( itIsTheSecondTuesday, nextSecondTuesday() );
setEvent( itIsTheSecondTuesday, nextSecondTuesday() );

}

void loop() {

time.events();
events();

}

Expand All @@ -29,7 +30,7 @@ void itIsTheSecondTuesday() {
Serial.println(UTC.dateTime());

// The event then sets a new event for the next time
UTC.setEvent( itIsTheSecondTuesday, nextSecondTuesday() );
setEvent( itIsTheSecondTuesday, nextSecondTuesday() );
}

time_t nextSecondTuesday() {
Expand All @@ -40,7 +41,7 @@ time_t nextSecondTuesday() {

while (t <= UTC.now()) {
// Try in current month first, if that has passed, loop once more for next month
t = time.makeOrdinalTime(12, 0, 0, SECOND, TUESDAY, m, y);
t = makeOrdinalTime(12, 0, 0, SECOND, TUESDAY, m, y);
m++;
if (m == 13) {
m = 1;
Expand Down
20 changes: 12 additions & 8 deletions examples/NoNetwork/NoNetwork.ino
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,34 @@
* offset to UTC.
*
* If you do not want to look up the posix string you can simply provide a name and
* the current UTC offset, like "PDT+7"
* the current UTC offset in hours _west_ of UTC, like "PDT+7"
*/


#include <ezTime.h>

#define LOCALTZ_POSIX "PST+8PDT,M3.2.0/2,M11.1.0/2" // US Pacific time
#define LOCALTZ_POSIX "CET-1CEST,M3.4.0/2,M10.4.0/3" // Time in Berlin

Timezone local;
Timezone berlin;
Timezone pacific;

void setup() {

Serial.begin(115200);
while (!Serial) { ; } // wait for Serial port to connect. Needed for native USB port only
Serial.println();

local.setPosix(LOCALTZ_POSIX);
local.setTime(time.compileTime());
Serial.println("Local time : " + local.dateTime());
local.setTime(compileTime());
Serial.print(F("Local time : "));
Serial.println(local.dateTime());

berlin.setPosix("CET-1CEST,M3.4.0/2,M10.4.0/3");
Serial.println("Berlin time : " + berlin.dateTime());
pacific.setPosix(F("PST+8PDT,M3.2.0/2,M11.1.0/2"));
Serial.print(F("Pacific time : "));
Serial.println(pacific.dateTime());

Serial.println("UTC : " + UTC.dateTime());
Serial.print(F("UTC : "));
Serial.println(UTC.dateTime());

}

Expand Down
33 changes: 17 additions & 16 deletions examples/TimeFormats/TimeFormats.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@
void setup() {

Serial.begin(115200);

WiFi.begin("your-ssid", "your-password");

time.waitForSync();
while (!Serial) { ; } // wait for Serial port to connect. Needed for native USB port only
waitForSync();

Serial.println();
Serial.println("Time in various internet standard formats ...");
Serial.println();
Serial.println("ATOM: " + UTC.dateTime(ATOM));
Serial.println("COOKIE: " + UTC.dateTime(COOKIE));
Serial.println("IS8601: " + UTC.dateTime(ISO8601));
Serial.println("RFC822: " + UTC.dateTime(RFC822));
Serial.println("RFC850: " + UTC.dateTime(RFC850));
Serial.println("RFC1036: " + UTC.dateTime(RFC1036));
Serial.println("RFC1123: " + UTC.dateTime(RFC1123));
Serial.println("RFC2822: " + UTC.dateTime(RFC2822));
Serial.println("RFC3339: " + UTC.dateTime(RFC3339));
Serial.println("RFC3339_EXT: " + UTC.dateTime(RFC3339_EXT));
Serial.println("RSS: " + UTC.dateTime(RSS));
Serial.println("W3C: " + UTC.dateTime(W3C));
Serial.println("ATOM: " + dateTime(ATOM));
Serial.println("COOKIE: " + dateTime(COOKIE));
Serial.println("IS8601: " + dateTime(ISO8601));
Serial.println("RFC822: " + dateTime(RFC822));
Serial.println("RFC850: " + dateTime(RFC850));
Serial.println("RFC1036: " + dateTime(RFC1036));
Serial.println("RFC1123: " + dateTime(RFC1123));
Serial.println("RFC2822: " + dateTime(RFC2822));
Serial.println("RFC3339: " + dateTime(RFC3339));
Serial.println("RFC3339_EXT: " + dateTime(RFC3339_EXT));
Serial.println("RSS: " + dateTime(RSS));
Serial.println("W3C: " + dateTime(W3C));
Serial.println();
Serial.println(" ... and any other format, like \"" + UTC.dateTime("l ~t~h~e jS ~o~f F Y, g:i A") + "\"");
Serial.println(" ... and any other format, like \"" + dateTime("l ~t~h~e jS ~o~f F Y, g:i A") + "\"");
}

void loop() {

events();
}
5 changes: 3 additions & 2 deletions examples/Timezones/Timezones.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
void setup() {

Serial.begin(115200);
while (!Serial) { ; } // wait for Serial port to connect. Needed for native USB port only
WiFi.begin("your-ssid", "your-password");

// Uncomment the line below to see what it does behind the scenes
// ezTime.debugLevel(INFO);

time.waitForSync();
waitForSync();

Serial.println();
Serial.println("UTC: " + UTC.dateTime());
Expand All @@ -24,5 +25,5 @@ void setup() {
}

void loop() {

events();
}
12 changes: 6 additions & 6 deletions examples/milliseconds/milliseconds.ino
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
void setup() {

Serial.begin(115200);
while (!Serial) { ; } // wait for Serial port to connect. Needed for native USB port only
WiFi.begin("your-ssid", "your-password");

time.setInterval(60);
time.waitForSync();
setInterval(60);
waitForSync();

Serial.println();

Expand All @@ -26,11 +27,10 @@ void setup() {
Serial.println("And ezTime is not making those milliseconds up either.");
Serial.println();
Serial.println(" ... Stick around as we do an NTP request every minute.");
ezTime.debugLevel(INFO);
debugLevel(INFO);

}

void loop() {
time.events();
delay(1000);
events();
}
Binary file added images/Arduino-Due.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Arduino-MKR-1000.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Arduino-Micro.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Arduino-Nano.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/ESP8266.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/M5Stack.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Teensy-3.2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/Uno-with-Ethernet.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions keywords.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# ezTime object

time KEYWORD3
error KEYWORD2
errorString KEYWORD2
debugLevel KEYWORD2
Expand Down Expand Up @@ -51,6 +48,7 @@ year KEYWORD2
dayOfYear KEYWORD2
weekISO KEYWORD2
yearISO KEYWORD2
militaryTZ KEYWORD2
setLocation KEYWORD2
setCache KEYWORD2
clearCache KEYWORD2
Expand Down
Loading

0 comments on commit c1f0778

Please sign in to comment.