diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2012-02-17 02:53:02 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2012-02-17 02:53:02 +0000 |
commit | 1906e9b50d5b13a1e4319ef97ec52cfac71b20cd (patch) | |
tree | fcc6857370879d5c74f9e838c10005b299b702a7 /epan/dissectors/packet-smpp.c | |
parent | 0a7df4d63cb227b9e4c3d1155c589e5b5b43c81e (diff) |
(Re)fix https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=6712 :
The change made in r40742 turned out to not be portable (FreeBSD doesn't have
the timezone global variable), so use another method to determine the current
timezone.
Also fix a bug introduced by r40742's change to display this timestamp in UTC:
if the reported (by the message) time zone has a negative offset to UTC, shift
it forward (not backward) to get UTC (and the opposite for positive offsets).
svn path=/trunk/; revision=41044
Diffstat (limited to 'epan/dissectors/packet-smpp.c')
-rw-r--r-- | epan/dissectors/packet-smpp.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/epan/dissectors/packet-smpp.c b/epan/dissectors/packet-smpp.c index 691b5e0728..35a20b4a06 100644 --- a/epan/dissectors/packet-smpp.c +++ b/epan/dissectors/packet-smpp.c @@ -1179,20 +1179,35 @@ smpp_mktime(const char *datestr, time_t *secs, int *nsecs) r_time.tm_isdst = -1; if (relative == FALSE) { + struct tm *gm, *local_time; + int gm_hour, gm_min; + time_t current_time; + *secs = mktime(&r_time); + /* Subtract out the timezone information since we will adjust for - * timezone below and then display in UTC. + * the presented time's timezone below and then display in UTC. + * + * To do that, first determine the current timezone's offset to UTC. */ -#ifdef _WIN32 - *secs -= _timezone; -#else - *secs -= timezone; -#endif + current_time = time(NULL); + gm = gmtime(¤t_time); + gm_hour = gm->tm_hour; + gm_min = gm->tm_min; + local_time = localtime(¤t_time); + /* Then subtract out that difference (whether the difference is + * measured in hours, minutes, or both). + */ + *secs -= 3600*(gm_hour - local_time->tm_hour); + *secs -= 60*(gm_min - local_time->tm_min); + *nsecs = (datestr[12] - '0') * 100000000; t_diff = (10 * (datestr[13] - '0') + (datestr[14] - '0')) * 900; - if (datestr[15] == '+') + if (datestr[15] == '-') + /* Represented time is behind UTC, shift it forward to UTC */ *secs += t_diff; - else if (datestr[15] == '-') + else if (datestr[15] == '+') + /* Represented time is ahead of UTC, shift it backward to UTC */ *secs -= t_diff; } else { *secs = r_time.tm_sec + 60 * |