Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples Timezones.ino proposed enhancement - thanks #155

Open
artofit opened this issue Jul 28, 2022 · 1 comment
Open

examples Timezones.ino proposed enhancement - thanks #155

artofit opened this issue Jul 28, 2022 · 1 comment

Comments

@artofit
Copy link

artofit commented Jul 28, 2022

#include <ezTime.h>
#include <WiFi.h>

void setup() {

Serial.begin(115200);

WiFi.begin("your-ssid", "your-password");
while (WiFi.status() != WL_CONNECTED) {
delay(750);
Serial.println("-no connected, retrying in 0.75sec");
}
Serial.println("");
Serial.println("WIFI CONNECTED!");
Timezone    Berlin;
waitForSync();
Berlin.setLocation("Europe/Berlin");
Berlin.setDefault();

Serial.println();
Serial.println("Time in various internet standard formats ...");
Serial.println();
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("l ~t~h~e jS ~o~f F Y, g:i A:\"" + dateTime("l ~t~h~e jS ~o~f F Y, g:i A") + "\"");
Serial.println("l j M Y, G:i\t\"" + dateTime("l j M Y, G:i") + "\"");
Serial.println("D G:i j F Y\t\"" + dateTime("D G:i - j F Y") + "\"");
Serial.println("e D H:i:s j F Y\t\"" + dateTime("e D H:i:s - j F Y") + "\"");
Serial.println("Y-m-d H:i:sP\t\"" + dateTime("Y-m-d H:i:sP") + "\"");
Serial.println("T Y-m-d H:i:s\t\"" + dateTime("T Y-m-d H:i:s") + "\"");

/*
IF you want the month's or day's name displayed in your language,
edit ezTime.h
search for
#define EZTIME_LANGUAGE
and change with your language
languages files are under src/lang
*/

}

void loop() {
events();
}

@rboeije1
Copy link

rboeije1 commented Feb 5, 2025

I can only agree. The 'setDefault()' does it. I was wondering why dateTime() was printing the wrong time, even in the example, while Berlin.dateTime() was correct. Until I saw your suggestion. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants