Skip to content

Feature/timezone by ip #1875

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Revers-BR
Copy link

Description

This pull request replaces the manual timezone configuration with dynamic timezone detection using the ezTime library. The device now determines its timezone based on the IP address using the public API ip-api.com.

Changes introduced

  • Integrated the ezTime library for timezone and NTP support
  • Replaced the setTimezone() function with setTimezoneByIP(), which:
    • Performs an HTTP GET request to retrieve timezone information based on IP
    • Calls tz.setLocation() using the received timezone string
    • Automatically synchronizes the device time using NTP (waitForSync())
  • Replaced getLocalTime() with ezTime::now() and localtime() for building the struct tm
  • Updated updateTimeDisplayData() to reflect the new timezone-aware implementation
  • Retained date/time formatting using strftime()

Benefits

  • Automatically handles Daylight Saving Time (DST) transitions
  • Eliminates the need for hardcoded POSIX timezone strings
  • Increases portability and flexibility for international deployments

Notes

  • Requires an active Wi-Fi connection to perform IP-based timezone detection
  • The ezTime library must be installed via the Arduino Library Manager

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

Successfully merging this pull request may close these issues.

1 participant