diff mbox

[4/4] gsm0411_utils: Use portable helper gmtoffset_from_ts helper in gsm340_scts

Message ID f951222ec3735c3f20bbd9940e06f48fd19012d7.1395872056.git.daniel@totalueberwachung.de
State New
Headers show

Commit Message

Daniel Willmann March 26, 2014, 10:30 p.m. UTC
Avoid depending on the presence of tm_gmtoff to calculate the gmt
offset.
---
 src/gsm/gsm0411_utils.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/src/gsm/gsm0411_utils.c b/src/gsm/gsm0411_utils.c
index c6d68bd..94d48fd 100644
--- a/src/gsm/gsm0411_utils.c
+++ b/src/gsm/gsm0411_utils.c
@@ -119,7 +119,7 @@  time_t gsm340_scts(uint8_t *scts)
 	struct tm tm;
 	uint8_t yr, tz;
 	int ofs;
-	time_t timestamp;
+	time_t timestamp, gmtoffset;
 
 	memset(&tm, 0x00, sizeof(struct tm));
 
@@ -151,12 +151,12 @@  time_t gsm340_scts(uint8_t *scts)
 	if (timestamp < 0)
 		return -1;
 
+	gmtoffset = gmtoffset_from_ts(timestamp);
+
 	/* Take into account timezone offset */
 	timestamp -= ofs;
-#ifdef HAVE_TM_GMTOFF_IN_TM
 	/* Remove an artificial timezone offset, introduced by mktime() */
-	timestamp += tm.tm_gmtoff;
-#endif
+	timestamp += gmtoffset;
 
 	return timestamp;
 }