NoNetwork.ino 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * This example also does something useful with "#define EZTIME_NETWORK_ENABLE" at the
  3. * start of ezTime.h commented out. It will start the time at the time the code was
  4. * compiled. You have to set your local timezone information by hand in the
  5. * LOCALTZ_POSIX define. (The string contains the names for your TZ in standard and
  6. * Daylight Saving Time, as well as the starting and ending point for DST and the
  7. * offset to UTC.
  8. *
  9. * If you do not want to look up the posix string you can simply provide a name and
  10. * the current UTC offset in hours _west_ of UTC, like "PDT+7"
  11. */
  12. #include <ezTime.h>
  13. #define LOCALTZ_POSIX "CET-1CEST,M3.4.0/2,M10.4.0/3" // Time in Berlin
  14. Timezone local;
  15. Timezone pacific;
  16. void setup() {
  17. Serial.begin(115200);
  18. while (!Serial) { ; } // wait for Serial port to connect. Needed for native USB port only
  19. Serial.println();
  20. local.setPosix(LOCALTZ_POSIX);
  21. local.setTime(compileTime());
  22. Serial.print(F("Local time : "));
  23. Serial.println(local.dateTime());
  24. pacific.setPosix(F("PST+8PDT,M3.2.0/2,M11.1.0/2"));
  25. Serial.print(F("Pacific time : "));
  26. Serial.println(pacific.dateTime());
  27. Serial.print(F("UTC : "));
  28. Serial.println(UTC.dateTime());
  29. }
  30. void loop() {
  31. }