Skip to content

Fix getTime() timezone #28

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 2 commits into
base: main
Choose a base branch
from

Conversation

pennam
Copy link
Contributor

@pennam pennam commented Jul 17, 2025

with this changes we ansure getTime is always using UTC timezone and we can check NTP is synced comparing output with UNIX epoch.

Copy link

Memory usage change @ 3b31d79

Board flash % RAM for global variables %
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 🔺 +360 - +456 +0.02 - +0.02 0 - 0 0.0 - 0.0
Click for full report table
Board examples/HTTPClient
flash
% examples/HTTPClient
RAM for global variables
% examples/HTTPSClient
flash
% examples/HTTPSClient
RAM for global variables
% examples/GetTime
flash
% examples/GetTime
RAM for global variables
% examples/GetLocation
flash
% examples/GetLocation
RAM for global variables
% examples/DeleteSMS
flash
% examples/DeleteSMS
RAM for global variables
% examples/ReceiveSMS
flash
% examples/ReceiveSMS
RAM for global variables
% examples/SendSMS
flash
% examples/SendSMS
RAM for global variables
% examples/ModemTerminal
flash
% examples/ModemTerminal
RAM for global variables
%
arduino:mbed_portenta:envie_m7 N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A N/A
arduino:renesas_portenta:portenta_c33 400 0.02 0 0.0 400 0.02 0 0.0 456 0.02 0 0.0 456 0.02 0 0.0 360 0.02 0 0.0 360 0.02 0 0.0 376 0.02 0 0.0 424 0.02 0 0.0
Click for full report CSV
Board,examples/HTTPClient<br>flash,%,examples/HTTPClient<br>RAM for global variables,%,examples/HTTPSClient<br>flash,%,examples/HTTPSClient<br>RAM for global variables,%,examples/GetTime<br>flash,%,examples/GetTime<br>RAM for global variables,%,examples/GetLocation<br>flash,%,examples/GetLocation<br>RAM for global variables,%,examples/DeleteSMS<br>flash,%,examples/DeleteSMS<br>RAM for global variables,%,examples/ReceiveSMS<br>flash,%,examples/ReceiveSMS<br>RAM for global variables,%,examples/SendSMS<br>flash,%,examples/SendSMS<br>RAM for global variables,%,examples/ModemTerminal<br>flash,%,examples/ModemTerminal<br>RAM for global variables,%
arduino:mbed_portenta:envie_m7,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A,N/A
arduino:renesas_portenta:portenta_c33,400,0.02,0,0.0,400,0.02,0,0.0,456,0.02,0,0.0,456,0.02,0,0.0,360,0.02,0,0.0,360,0.02,0,0.0,376,0.02,0,0.0,424,0.02,0,0.0

@per1234 per1234 added type: imperfection Perceived defect in any part of project topic: code Related to content of the project itself labels Jul 19, 2025
Copy link
Contributor

@sebromero sebromero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but please add a comment here and mention that this function will try to sync with an NTP server to get the current time.

@sebromero
Copy link
Contributor

@pennam Actually this is already implemented in the function getCellularTime. Can we use that one instead?

@sebromero
Copy link
Contributor

@pennam We would need to change getNetworkTime to getNetworkUTCTime inside getCellularTime. Not sure this has any side effects.

@pennam
Copy link
Contributor Author

pennam commented Jul 21, 2025

getTime() is a private static function of the library, used to feed BearSSLClient as callback, it have to return time in UTC format and it cannot be called as cellular.getTime() and we cannot feed BearSSLClient with getCellularTime()

To keep backward compatibility I've added a flag to getCellularTime() adding the possibility for the user the get localtime or utc time 4b7a446

I'm splitting PR #29 to reduce the scope and make it more simple to review

@pennam pennam closed this Jul 21, 2025
@pennam pennam reopened this Jul 21, 2025
@pennam
Copy link
Contributor Author

pennam commented Jul 21, 2025

To avoid duplication of NTPSync code we can add a private static method that only takes care of the NTPsync call and is called by both getTime() and getCellularTime().

@pennam
Copy link
Contributor Author

pennam commented Jul 22, 2025

@sebromero please take a look at #32 🙂

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: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants