mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
arch/nrf91: convert GNSS UTC time with timegm() not mktime()
The GNSS datetime reported by the modem is UTC. mktime() interprets the broken-down time as local time, so a configured timezone would skew the reported epoch. Use timegm() to convert it directly as UTC. Signed-off-by: raiden00pl <raiden00@railab.me>
This commit is contained in:
parent
2bcc59b42f
commit
3a8d4ba3dd
1 changed files with 8 additions and 2 deletions
|
|
@ -223,7 +223,8 @@ static bool nrf91_gnss_isactive(int cfun)
|
|||
*
|
||||
* Description:
|
||||
* Configure and start the GNSS engine. The caller must have verified that
|
||||
* the modem is in a GNSS-capable functional mode (see nrf91_gnss_isactive).
|
||||
* the modem is in a GNSS-capable functional mode
|
||||
* (see nrf91_gnss_isactive).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
|
@ -510,7 +511,12 @@ static void nrf91_gnss_pvt_event(struct nrf91_gnss_s *priv)
|
|||
tm.tm_isdst = 0;
|
||||
|
||||
gps.timestamp = timestamp;
|
||||
gps.time_utc = mktime(&tm);
|
||||
|
||||
/* The GNSS datetime is UTC; use timegm() (not mktime(), which would
|
||||
* apply the local timezone) to convert it to epoch seconds.
|
||||
*/
|
||||
|
||||
gps.time_utc = timegm(&tm);
|
||||
gps.latitude = priv->pvt.latitude;
|
||||
gps.longitude = priv->pvt.longitude;
|
||||
gps.altitude = priv->pvt.altitude;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue