SMPP: use mktime_utc to convert struct tm to time_t

Bug: 12632
Change-Id: Ie340facff86d988b7a85f6351d85343169042ce9
Reviewed-on: https://code.wireshark.org/review/18155
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Pascal Quantin 2016-10-11 21:58:29 +02:00 committed by Anders Broman
parent 50ddeaadf9
commit aa78460ef9
1 changed files with 2 additions and 26 deletions

View File

@ -54,8 +54,8 @@
#include <epan/packet.h>
#include <epan/exceptions.h>
#include <epan/stats_tree.h>
#include <epan/prefs.h>
#include <wsutil/time_util.h>
#include "packet-tcp.h"
#include "packet-smpp.h"
@ -1174,10 +1174,7 @@ 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;
*secs = mktime(&r_time);
*secs = mktime_utc(&r_time);
*nsecs = 0;
if (*secs == (time_t)(-1)) {
return relative;
@ -1191,27 +1188,6 @@ smpp_mktime(const char *datestr, time_t *secs, int *nsecs)
else if (datestr[15] == '+')
/* Represented time is ahead of UTC, shift it backward to UTC */
*secs -= t_diff;
/* Subtract out the timezone information since we adjusted for
* the presented time's timezone above and will display in UTC.
*
* To do that, first determine how the time is represented in the
* local time zone and in UTC.
*/
if (((gm = gmtime(secs)) == NULL) || ((local_time = localtime(secs)) == NULL)) {
*secs = (time_t)(-1);
*nsecs = 0;
return relative;
}
gm_hour = gm->tm_hour;
gm_min = gm->tm_min;
/* Then subtract out the difference between those times (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);
} else {
*secs = r_time.tm_sec + 60 *
(r_time.tm_min + 60 *