@@ -72,6 +72,24 @@ uint8_t gsm411_unbcdify(uint8_t value)
return ret;
}
+/* Figure out the timezone offset in a portable way.
+ * The idea is to convert the time_t into local and UTC struct tm
+ * representations and then calculate the difference of both. */
+static time_t gmtoffset_from_ts(time_t time)
+{
+ struct tm tm_local, tm_utc;
+ time_t ts_local, ts_utc;
+
+ localtime_r(&time, &tm_local);
+ gmtime_r(&time, &tm_utc);
+ tm_utc.tm_isdst = 0;
+ tm_local.tm_isdst = 0;
+ ts_utc = mktime(&tm_utc);
+ ts_local = mktime(&tm_local);
+
+ return ts_local - ts_utc;
+}
+
/* Generate 03.40 TP-SCTS */
void gsm340_gen_scts(uint8_t *scts, time_t time)
{