Getting NTP localtime without config?

rin67630
Posts: 139
Joined: Sun Mar 11, 2018 5:13 pm

Getting NTP localtime without config?

Postby rin67630 » Tue Jul 16, 2024 5:03 pm

Hi, do we have a way to get NTP localtime without a manual configuration?
I mean with the callling IP, a geolocation can be done and out of that the time zone parameters TZ and DST_MN automatically derived, isn't it?

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Getting NTP localtime without config?

Postby lbernstone » Tue Jul 16, 2024 5:48 pm

Geolocation is a service provided by a 3rd party. Those services are generally not free (as in the GPL definition of free). They are free (as in beer), from many sites after a registration. Here's an example

My preference nowadays is to get the timezone and utc from a web client through a hidden element in a form. It's been on my list to make a demo of that. I'll post an example here when I extract that from a larger project (and convert it to arduino).

rin67630
Posts: 139
Joined: Sun Mar 11, 2018 5:13 pm

Re: Getting NTP localtime without config?

Postby rin67630 » Tue Jul 16, 2024 7:55 pm

lbernstone wrote:
Tue Jul 16, 2024 5:48 pm
Geolocation is a service provided by a 3rd party. Those services are generally not free (as in the GPL definition of free). They are free (as in beer), from many sites after a registration. Here's an example

My preference nowadays is to get the timezone and utc from a web client through a hidden element in a form. It's been on my list to make a demo of that. I'll post an example here when I extract that from a larger project (and convert it to arduino).
Thank you!
That's a lot of stuff to just derive one's TZ and DST_MN.

In fact, I can get from another site my current timezone in a verbose form. e.g.: "Europe/Berlin".
Is it easier to get TZ and DST_MN from that?
Or have we got a way to call NTP with this info instead of TZ and DST_MN?

Regards
Laszlo

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Getting NTP localtime without config?

Postby lbernstone » Thu Jul 18, 2024 3:30 am

Last edited by lbernstone on Thu Jul 18, 2024 4:48 pm, edited 1 time in total.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Getting NTP localtime without config?

Postby lbernstone » Thu Jul 18, 2024 3:55 am

NTP uses UTC time. Always. Period.
The timezone can be set manually by calling

Code: Select all

    char tz[] = "HST10";
    setenv("TZ", tz, 1);
    tzset();
The strings that are recognized are compiled in the crossNG toolchain. I am pretty certain that all the ST/DT strings in my zones file are recognized. The city name strings may or may not be.

rin67630
Posts: 139
Joined: Sun Mar 11, 2018 5:13 pm

Re: Getting NTP localtime without config?

Postby rin67630 » Fri Jul 19, 2024 11:28 am

lbernstone wrote:
Thu Jul 18, 2024 3:55 am
NTP uses UTC time. Always. Period.
Sure. We are speaking about about the ESP library, which needs TZ and DST values to get the local time.

lbernstone
Posts: 826
Joined: Mon Jul 22, 2019 3:20 pm

Re: Getting NTP localtime without config?

Postby lbernstone » Fri Jul 19, 2024 11:03 pm

simpson_robot_never_worked.gif
simpson_robot_never_worked.gif (1.16 MiB) Viewed 2684 times

rin67630
Posts: 139
Joined: Sun Mar 11, 2018 5:13 pm

Re: Getting NTP localtime without config?

Postby rin67630 » Sun Jul 21, 2024 4:53 pm

lbernstone wrote:
Fri Jul 19, 2024 11:03 pm
simpson_robot_never_worked.gif
Very intelligent post...

Who is online

Users browsing this forum: Bing [Bot] and 31 guests