comparison src/util.c @ 13333:b04212d6b115

[gaim-migrate @ 15703] win32 TZ name to abbreviation conversion. This make the behavior consistent across platforms. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Mon, 27 Feb 2006 08:49:14 +0000
parents 2990bc8c89fa
children 554575d1f9b5
comparison
equal deleted inserted replaced
13332:97545c71d208 13333:b04212d6b115
527 if (g_snprintf(buf, sizeof(buf), "%+03d%02d", hrs, ABS(min)) > 5) 527 if (g_snprintf(buf, sizeof(buf), "%+03d%02d", hrs, ABS(min)) > 5)
528 g_return_val_if_reached(""); 528 g_return_val_if_reached("");
529 529
530 return buf; 530 return buf;
531 } 531 }
532 532 #endif
533
534 /* Windows doesn't HAVE_STRFTIME_Z_FORMAT, but this seems clearer. -- rlaager */
535 #if !defined(HAVE_STRFTIME_Z_FORMAT) || defined(_WIN32)
533 static size_t gaim_internal_strftime(char *s, size_t max, const char *format, const struct tm *tm) 536 static size_t gaim_internal_strftime(char *s, size_t max, const char *format, const struct tm *tm)
534 { 537 {
535 const char *start; 538 const char *start;
536 const char *c; 539 const char *c;
537 char *fmt = NULL; 540 char *fmt = NULL;
539 /* Yes, this is checked in gaim_utf8_strftime(), 542 /* Yes, this is checked in gaim_utf8_strftime(),
540 * but better safe than sorry. -- rlaager */ 543 * but better safe than sorry. -- rlaager */
541 g_return_val_if_fail(format != NULL, 0); 544 g_return_val_if_fail(format != NULL, 0);
542 545
543 /* This is fairly efficient, and it only gets 546 /* This is fairly efficient, and it only gets
544 * executed if the underlying system doesn't 547 * executed on Windows or if the underlying
545 * support the %z format string for strftime(), 548 * system doesn't support the %z format string,
546 * so I think it's good enough. -- rlaager */ 549 * for strftime() so I think it's good enough.
550 * -- rlaager */
547 for (c = start = format; *c ; c++) 551 for (c = start = format; *c ; c++)
548 { 552 {
549 if (*c != '%') 553 if (*c != '%')
550 continue; 554 continue;
551 555
552 c++; 556 c++;
553 557
558 #ifndef HAVE_STRFTIME_Z_FORMAT
554 if (*c == 'z') 559 if (*c == 'z')
555 { 560 {
556 char *tmp = g_strdup_printf("%s%.*s%s", 561 char *tmp = g_strdup_printf("%s%.*s%s",
557 fmt ? fmt : "", 562 fmt ? fmt : "",
558 c - start - 1, 563 c - start - 1,
560 get_tmoff(tm)); 565 get_tmoff(tm));
561 g_free(fmt); 566 g_free(fmt);
562 fmt = tmp; 567 fmt = tmp;
563 start = c + 1; 568 start = c + 1;
564 } 569 }
570 #endif
571 #ifdef _WIN32
572 if (*c == 'Z')
573 {
574 char *tmp = g_strdup_printf("%s%.*s%s",
575 fmt ? fmt : "",
576 c - start - 1,
577 start,
578 wgaim_get_timezone_abbreviation(tm));
579 g_free(fmt);
580 fmt = tmp;
581 start = c + 1;
582 }
583 #endif
565 } 584 }
566 585
567 if (fmt != NULL) 586 if (fmt != NULL)
568 { 587 {
569 size_t ret; 588 size_t ret;
581 return ret; 600 return ret;
582 } 601 }
583 602
584 return strftime(s, max, format, tm); 603 return strftime(s, max, format, tm);
585 } 604 }
586 #else /* HAVE_STRFTIME_Z_FORMAT */ 605 #else /* HAVE_STRFTIME_Z_FORMAT && !_WIN32 */
587 #define gaim_internal_strftime strftime 606 #define gaim_internal_strftime strftime
588 #endif 607 #endif
589 608
590 const char * 609 const char *
591 gaim_utf8_strftime(const char *format, const struct tm *tm) 610 gaim_utf8_strftime(const char *format, const struct tm *tm)