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

Add offline time update to NTPClient capability #153

Open
saifuhameed opened this issue Oct 6, 2021 · 1 comment
Open

Add offline time update to NTPClient capability #153

saifuhameed opened this issue Oct 6, 2021 · 1 comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@saifuhameed
Copy link

saifuhameed commented Oct 6, 2021

In my application NTPClient is used to get time for logging and displaying IOT events.
We expect device to display IOT data through local webserver even without internet.
But there is a problem, event time will be wrong due to there is no internet. So I suggest to add a function to enable offline updating of date and time, so that it will give at least actual date and time with reduced accuracy. Offline updating can be done from a settings page of IOT application, user can update date and time on device startup.
This feature can be easily accommodated by adding a function to update _lastUpdate and _currentEpoc manually.

@per1234 per1234 added topic: code Related to content of the project itself type: enhancement Proposed improvement labels Jan 30, 2022
@Walorikot
Copy link

Walorikot commented Mar 25, 2024

You can update the current time manually through the offset:

  // Setup
  WiFiUDP ntpUDP;
  NTPClient timeClient(ntpUDP);
  // Update
  timeClient.setTimeOffset(currentEpoch - millis() / 1000);

The last part tries to compensate _lastUpdate. It is the best solution I've found so far and it is not accurate. There should be an easier way to do this. Hopefully this library will get this feature.

@per1234 per1234 changed the title Feature request: Offline time update to NTPClient Add offline time update to NTPClient capability Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

No branches or pull requests

3 participants