diff options
Diffstat (limited to 'channels/misdn')
-rw-r--r-- | channels/misdn/ie.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/channels/misdn/ie.c b/channels/misdn/ie.c index 4093805b5..e7133ca75 100644 --- a/channels/misdn/ie.c +++ b/channels/misdn/ie.c @@ -852,17 +852,11 @@ static void enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int nt, s unsigned char *p; Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN); int l; + struct timeval tv = { ti, 0 }; + struct ast_tm tm; - struct tm *tm; - - tm = localtime(&ti); - if (!tm) - { - printf("%s: ERROR: gettimeofday() returned NULL.\n", __FUNCTION__); - return; - } - - if (MISDN_IE_DEBG) printf(" year=%d month=%d day=%d hour=%d minute=%d\n", tm->tm_year%100, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min); + ast_localtime(&tv, &tm, NULL); + if (MISDN_IE_DEBG) printf(" year=%d month=%d day=%d hour=%d minute=%d\n", tm.tm_year%100, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min); l = 5; p = msg_put(msg, l+2); @@ -872,11 +866,11 @@ static void enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int nt, s qi->QI_ELEMENT(date) = p - (unsigned char *)qi - sizeof(Q931_info_t); p[0] = IE_DATE; p[1] = l; - p[2] = tm->tm_year % 100; - p[3] = tm->tm_mon + 1; - p[4] = tm->tm_mday; - p[5] = tm->tm_hour; - p[6] = tm->tm_min; + p[2] = tm.tm_year % 100; + p[3] = tm.tm_mon + 1; + p[4] = tm.tm_mday; + p[5] = tm.tm_hour; + p[6] = tm.tm_min; } |