[asterisk-commits] tilghman: branch group/ast_strftime r75705 - in /team/group/ast_strftime: app...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jul 18 14:35:35 CDT 2007


Author: tilghman
Date: Wed Jul 18 14:35:35 2007
New Revision: 75705

URL: http://svn.digium.com/view/asterisk?view=rev&rev=75705
Log:
A few more conversions to struct ast_tm (with microseconds)

Modified:
    team/group/ast_strftime/apps/app_rpt.c
    team/group/ast_strftime/apps/app_sms.c
    team/group/ast_strftime/channels/chan_skinny.c
    team/group/ast_strftime/channels/misdn/ie.c

Modified: team/group/ast_strftime/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_strftime/apps/app_rpt.c?view=diff&rev=75705&r1=75704&r2=75705
==============================================================================
--- team/group/ast_strftime/apps/app_rpt.c (original)
+++ team/group/ast_strftime/apps/app_rpt.c Wed Jul 18 14:35:35 2007
@@ -1891,7 +1891,7 @@
 	struct ast_channel *mychannel;
 	const char *p, *ct;
 	time_t t;
-	struct tm localtm;
+	struct ast_tm localtm;
 #ifdef  APP_RPT_LOCK_DEBUG
 	struct lockthread *t;
 #endif
@@ -5620,7 +5620,7 @@
 static void do_scheduler(struct rpt *myrpt)
 {
 	int res;
-	struct tm tmnow;
+	struct ast_tm tmnow;
 
 	memcpy(&myrpt->lasttv, &myrpt->curtv, sizeof(struct timeval));
 	

Modified: team/group/ast_strftime/apps/app_sms.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_strftime/apps/app_sms.c?view=diff&rev=75705&r1=75704&r2=75705
==============================================================================
--- team/group/ast_strftime/apps/app_sms.c (original)
+++ team/group/ast_strftime/apps/app_sms.c Wed Jul 18 14:35:35 2007
@@ -549,7 +549,7 @@
 		t.tm_min += 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
 	else
 		t.tm_min -= 15 * ((i[6] & 0x7) * 10 + (i[6] >> 4));
-	return mktime((struct tm *)&t);
+	return mktime(&t);
 }
 
 /*! \brief unpacks bytes (7 bit encoding) at i, len l septets, 

Modified: team/group/ast_strftime/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_strftime/channels/chan_skinny.c?view=diff&rev=75705&r1=75704&r2=75705
==============================================================================
--- team/group/ast_strftime/channels/chan_skinny.c (original)
+++ team/group/ast_strftime/channels/chan_skinny.c Wed Jul 18 14:35:35 2007
@@ -3735,21 +3735,21 @@
 
 static int handle_time_date_req_message(struct skinny_req *req, struct skinnysession *s)
 {
-	time_t timer;
-	struct tm *cmtime;
+	struct timeval tv = ast_tvnow();
+	struct ast_tm cmtime;
 
 	if (!(req = req_alloc(sizeof(struct definetimedate_message), DEFINETIMEDATE_MESSAGE)))
 		return -1;
 
-	timer = time(NULL);
-	cmtime = localtime(&timer);
-	req->data.definetimedate.year = htolel(cmtime->tm_year+1900);
-	req->data.definetimedate.month = htolel(cmtime->tm_mon+1);
-	req->data.definetimedate.dayofweek = htolel(cmtime->tm_wday);
-	req->data.definetimedate.day = htolel(cmtime->tm_mday);
-	req->data.definetimedate.hour = htolel(cmtime->tm_hour);
-	req->data.definetimedate.minute = htolel(cmtime->tm_min);
-	req->data.definetimedate.seconds = htolel(cmtime->tm_sec);
+	ast_localtime(&tv, &cmtime, NULL);
+	req->data.definetimedate.year = htolel(cmtime.tm_year+1900);
+	req->data.definetimedate.month = htolel(cmtime.tm_mon+1);
+	req->data.definetimedate.dayofweek = htolel(cmtime.tm_wday);
+	req->data.definetimedate.day = htolel(cmtime.tm_mday);
+	req->data.definetimedate.hour = htolel(cmtime.tm_hour);
+	req->data.definetimedate.minute = htolel(cmtime.tm_min);
+	req->data.definetimedate.seconds = htolel(cmtime.tm_sec);
+	req->data.definetimedate.milliseconds = htolel(cmtime.tm_usec / 1000);
 	transmit_response(s, req);
 	return 1;
 }

Modified: team/group/ast_strftime/channels/misdn/ie.c
URL: http://svn.digium.com/view/asterisk/team/group/ast_strftime/channels/misdn/ie.c?view=diff&rev=75705&r1=75704&r2=75705
==============================================================================
--- team/group/ast_strftime/channels/misdn/ie.c (original)
+++ team/group/ast_strftime/channels/misdn/ie.c Wed Jul 18 14:35:35 2007
@@ -852,17 +852,11 @@
 	unsigned char *p;
 	Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
 	int l;
-
-	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);
+	struct timeval tv = { ti, 0 };
+	struct ast_tm tm;
+
+	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 @@
 		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;
 }
 
 




More information about the asterisk-commits mailing list