Skip to content

Commit 4b7a446

Browse files
committed
getCellularTime add flag to select local/UTC time
1 parent 8efd7f4 commit 4b7a446

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/ArduinoCellular.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Time ArduinoCellular::getGPSTime(){
126126
return Time(year, month, day, hour, minute, second);
127127
}
128128

129-
Time ArduinoCellular::getCellularTime(){
129+
Time ArduinoCellular::getCellularTime(bool localTime){
130130
int year = 1970;
131131
int month = 1;
132132
int day = 1;
@@ -135,7 +135,11 @@ Time ArduinoCellular::getCellularTime(){
135135
int second = 0;
136136
float tz;
137137
if (modem.NTPServerSync() == 0) {
138-
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
138+
if (localTime) {
139+
modem.getNetworkTime(&year, &month, &day, &hour, &minute, &second, &tz);
140+
} else {
141+
modem.getNetworkUTCTime(&year, &month, &day, &hour, &minute, &second, &tz);
142+
}
139143
}
140144
return Time(year, month, day, hour, minute, second);
141145
}

src/ArduinoCellular.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ class ArduinoCellular {
163163
* @brief Gets the current time from the network.
164164
* @return The current time.
165165
*/
166-
Time getCellularTime();
166+
Time getCellularTime(bool localTime = true);
167167

168168
/**
169169
* @brief Gets the current time from the GPS module.

0 commit comments

Comments
 (0)