Changeset 1225:ce8bc8227ef4 in freeDiameter
- Timestamp:
- Jul 17, 2013, 2:23:33 AM (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libfdproto/dictionary_functions.c
r1222 r1225 35 35 36 36 #include "fdproto-internal.h" 37 #include <time.h> 37 38 38 39 /* This file contains helpers functions to be reused as callbacks in the struct dict_type_data structure. … … 306 307 } 307 308 309 static void _format_offs (long offset, char *buf) { 310 int offs_hours, offs_minutes, sgn = 1; 311 if (offset < 0) { 312 offset = -offset; 313 sgn = 1; 314 } 315 offs_hours = (int)(offset/3600); 316 offs_minutes = (offset%3600)/60; 317 318 char* s = buf; 319 320 *(s++) = sgn == 1 ? '+' : '-'; 321 *(s++) = (char)(offs_hours/10) + '0'; 322 *(s++) = offs_hours%10 + '0'; 323 324 if (offs_minutes == 0) { 325 *(s++) = '\0'; 326 } else { 327 *(s++) = (char)(offs_minutes/10) + '0'; 328 *(s++) = offs_minutes%10 + '0'; 329 *(s++) = '\0'; 330 } 331 } 332 308 333 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value) 309 334 { 310 335 time_t val; 311 336 struct tm conv; 337 char tz_buf[7]; 312 338 313 339 FD_DUMP_HANDLE_OFFSET(); … … 323 349 } 324 350 325 CHECK_MALLOC_DO ( gmtime_r(&val, &conv), return NULL); 326 CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "%d%02d%02dT%02d%02d%02d+00", conv.tm_year+1900, conv.tm_mon+1, conv.tm_mday, conv.tm_hour, conv.tm_min, conv.tm_sec), return NULL); 351 CHECK_MALLOC_DO( localtime_r(&val, &conv), return NULL); 352 _format_offs(conv.tm_gmtoff, tz_buf); 353 CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "%d%02d%02dT%02d%02d%02d%s", conv.tm_year+1900, conv.tm_mon+1, conv.tm_mday, conv.tm_hour, conv.tm_min, conv.tm_sec, tz_buf), return NULL); 327 354 return *buf; 328 355 }
Note: See TracChangeset
for help on using the changeset viewer.