diff options
author | Benoit Bolsee <benoit.bolsee@wtl.be> | 2017-07-05 12:57:16 +0200 |
---|---|---|
committer | Neels Hofmeyr <neels@hofmeyr.de> | 2017-08-27 03:52:45 +0200 |
commit | 6012142f04f7b5d0ba79b01a24b9586e404ec712 (patch) | |
tree | 53e7ddf9667ba9cf052da4af465cb0c6c65ecca9 /src | |
parent | 5f4c357d19d4ab9a35ae8a1a4a6e0b850cbe02a3 (diff) |
04.08: find a portable way to obtain the timezone offset
Portable GMT offset calculation to display correct
time on GSM.
Change-Id: I673f17af2550c9708c4771e4ea4eafbbfafbb824
Diffstat (limited to 'src')
-rw-r--r-- | src/libmsc/gsm_04_08.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c index d97bde235..58c561058 100644 --- a/src/libmsc/gsm_04_08.c +++ b/src/libmsc/gsm_04_08.c @@ -496,12 +496,19 @@ int gsm48_tx_mm_info(struct gsm_subscriber_connection *conn) else { /* Need to get GSM offset and convert into 15 min units */ /* This probably breaks if gmtoff returns a value not evenly divisible by 15? */ - local_time = localtime(&cur_t); #ifdef HAVE_TM_GMTOFF_IN_TM + local_time = localtime(&cur_t); tzunits = (local_time->tm_gmtoff/60)/15; #else -#warning find a portable way to obtain the timezone offset - tzunits = 0; + /* find timezone offset */ + time_t utc; + double offsetFromUTC; + utc = mktime(gmt_time); + local_time = localtime(&cur_t); + offsetFromUTC = difftime(cur_t, utc); + if (local_time->tm_isdst) + offsetFromUTC += 3600.0; + tzunits = ((int)offsetFromUTC) / 60 / 15; #endif if (tzunits < 0) { tzunits = tzunits/-1; |