This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3a8d4ba3dd4d547e043326b0584d8a8e53ebf24b Author: raiden00pl <[email protected]> AuthorDate: Fri Jun 12 19:15:41 2026 +0200 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 <[email protected]> --- arch/arm/src/nrf91/nrf91_modem_gnss.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/nrf91/nrf91_modem_gnss.c b/arch/arm/src/nrf91/nrf91_modem_gnss.c index b5539567a95..79298234e41 100644 --- a/arch/arm/src/nrf91/nrf91_modem_gnss.c +++ b/arch/arm/src/nrf91/nrf91_modem_gnss.c @@ -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;
