This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/3612
04.08: find a portable way to obtain the timezone offset
Portable GMT offset calculation to display correct
time on GSM.
Change-Id: I673f17af2550c9708c4771e4ea4eafbbfafbb824
---
M src/libmsc/gsm_04_08.c
1 file changed, 10 insertions(+), 3 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/12/3612/1
diff --git a/src/libmsc/gsm_04_08.c b/src/libmsc/gsm_04_08.c
index 3f3f905..a4e16fb 100644
--- a/src/libmsc/gsm_04_08.c
+++ b/src/libmsc/gsm_04_08.c
@@ -496,12 +496,19 @@
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;
--
To view, visit https://gerrit.osmocom.org/3612
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I673f17af2550c9708c4771e4ea4eafbbfafbb824
Gerrit-PatchSet: 1
Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>