Mercurial > pidgin
comparison libpurple/protocols/jabber/iq.c @ 25657:af351471ec5a
Report the correct UTC time (thanks for noticing this, Marcus).
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 08 Feb 2009 21:56:03 +0000 |
parents | a4cba207068f |
children | 43c41aee8fcb |
comparison
equal
deleted
inserted
replaced
25656:d1a0e487d45f | 25657:af351471ec5a |
---|---|
171 xmlnode *child) | 171 xmlnode *child) |
172 { | 172 { |
173 const char *xmlns; | 173 const char *xmlns; |
174 JabberIq *iq; | 174 JabberIq *iq; |
175 time_t now_t; | 175 time_t now_t; |
176 struct tm now_local; | |
177 struct tm now_utc; | |
176 struct tm *now; | 178 struct tm *now; |
177 | 179 |
178 time(&now_t); | 180 time(&now_t); |
179 now = localtime(&now_t); | 181 now = localtime(&now_t); |
182 memcpy(&now_local, now, sizeof(struct tm)); | |
183 now = gmtime(&now_t); | |
184 memcpy(&now_utc, now, sizeof(struct tm)); | |
180 | 185 |
181 xmlns = xmlnode_get_namespace(child); | 186 xmlns = xmlnode_get_namespace(child); |
182 | 187 |
183 if(type == JABBER_IQ_GET) { | 188 if(type == JABBER_IQ_GET) { |
184 xmlnode *utc; | 189 xmlnode *utc; |
192 child = xmlnode_new_child(iq->node, child->name); | 197 child = xmlnode_new_child(iq->node, child->name); |
193 xmlnode_set_namespace(child, xmlns); | 198 xmlnode_set_namespace(child, xmlns); |
194 utc = xmlnode_new_child(child, "utc"); | 199 utc = xmlnode_new_child(child, "utc"); |
195 | 200 |
196 if(!strcmp("urn:xmpp:time", xmlns)) { | 201 if(!strcmp("urn:xmpp:time", xmlns)) { |
197 tz = purple_get_tzoff_str(now, TRUE); | 202 tz = purple_get_tzoff_str(&now_local, TRUE); |
198 xmlnode_insert_data(xmlnode_new_child(child, "tzo"), tz, -1); | 203 xmlnode_insert_data(xmlnode_new_child(child, "tzo"), tz, -1); |
199 | 204 |
200 date = purple_utf8_strftime("%FT%TZ", now); | 205 date = purple_utf8_strftime("%FT%TZ", &now_utc); |
201 xmlnode_insert_data(utc, date, -1); | 206 xmlnode_insert_data(utc, date, -1); |
202 } else { /* jabber:iq:time */ | 207 } else { /* jabber:iq:time */ |
203 tz = purple_utf8_strftime("%Z", now); | 208 tz = purple_utf8_strftime("%Z", &now_local); |
204 xmlnode_insert_data(xmlnode_new_child(child, "tz"), tz, -1); | 209 xmlnode_insert_data(xmlnode_new_child(child, "tz"), tz, -1); |
205 | 210 |
206 date = purple_utf8_strftime("%Y%m%dT%T", now); | 211 date = purple_utf8_strftime("%Y%m%dT%T", &now_utc); |
207 xmlnode_insert_data(utc, date, -1); | 212 xmlnode_insert_data(utc, date, -1); |
208 | 213 |
209 display = purple_utf8_strftime("%d %b %Y %T", now); | 214 display = purple_utf8_strftime("%d %b %Y %T", &now_local); |
210 xmlnode_insert_data(xmlnode_new_child(child, "display"), display, -1); | 215 xmlnode_insert_data(xmlnode_new_child(child, "display"), display, -1); |
211 } | 216 } |
212 | 217 |
213 jabber_iq_send(iq); | 218 jabber_iq_send(iq); |
214 } | 219 } |