# HG changeset patch # User Sean Egan # Date 1070237388 0 # Node ID 5c5acdf8b98293627952928245764195bcdf390a # Parent 66d9440db6ec3aa7838c912e69bff6b99500da52 [gaim-migrate @ 8320] Ambrose C. Li made the log viewer right for you international folk. Thanks, Ambrose! committer: Tailor Script diff -r 66d9440db6ec -r 5c5acdf8b982 src/gtklog.c --- a/src/gtklog.c Sun Nov 30 23:49:45 2003 +0000 +++ b/src/gtklog.c Mon Dec 01 00:09:48 2003 +0000 @@ -92,7 +92,11 @@ GtkTreeIter iter; GaimLog *log = logs->data; char title[64]; + char *title_utf8; /* temporary variable for utf8 conversion */ strftime(title, sizeof(title), "%c", localtime(&log->time)); + title_utf8 = gaim_utf8_try_convert(title); + strncpy(title, title_utf8, sizeof(title)); + g_free(title_utf8); gtk_tree_store_append (lv->treestore, &iter, NULL); gtk_tree_store_set(lv->treestore, &iter, 0, title, @@ -139,6 +143,7 @@ char time[64]; char *title; + char *title_utf8; /* temporary variable for utf8 conversion */ if (! gtk_tree_selection_get_selected (sel, &model, &iter)) return; @@ -153,6 +158,9 @@ viewer->flags = flags; strftime(time, sizeof(time), "%c", localtime(&log->time)); title = g_strdup_printf("%s - %s", log->name, time); + title_utf8 = gaim_utf8_try_convert(title); + g_free(title); + title = title_utf8; gtk_window_set_title(GTK_WINDOW(viewer->window), title); gtk_imhtml_clear(GTK_IMHTML(viewer->imhtml)); gtk_imhtml_append_text(GTK_IMHTML(viewer->imhtml), read, @@ -177,11 +185,15 @@ This is a tree made from logs */ { char title[64]; + char *title_utf8; /* temporary variable for utf8 conversion */ GtkTreeIter iter; GList *logs = lv->logs; while (logs) { GaimLog *log = logs->data; strftime(title, sizeof(title), "%c", localtime(&log->time)); + title_utf8 = gaim_utf8_try_convert(title); + strncpy(title, title_utf8, sizeof(title)); + g_free(title_utf8); gtk_tree_store_append (lv->treestore, &iter, NULL); gtk_tree_store_set(lv->treestore, &iter, 0, title, diff -r 66d9440db6ec -r 5c5acdf8b982 src/log.c --- a/src/log.c Sun Nov 30 23:49:45 2003 +0000 +++ b/src/log.c Mon Dec 01 00:09:48 2003 +0000 @@ -706,9 +706,8 @@ char buf[BUF_LONG]; struct tm tm; struct old_logger_data *data = NULL; - char day[4], month[4], year[5]; + char month[4]; char *logfile = g_strdup_printf("%s.log", gaim_normalize(account, sn)); - char *date; char *path = g_build_filename(gaim_user_dir(), "logs", logfile, NULL); char *newlog; @@ -726,7 +725,6 @@ if ((newlog = strstr(buf, "---- New C"))) { int length; int offset; - GDate gdate; char convostart[32]; char *temp = strchr(buf, '@'); @@ -769,16 +767,36 @@ g_snprintf(convostart, length, "%s", temp); - sscanf(convostart, "%*s %s %s %d:%d:%d %s", - month, day, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, year); - date = g_strdup_printf("%s %s %s", month, day, year); - g_date_set_parse(&gdate, date); - tm.tm_mday = g_date_get_day(&gdate); - tm.tm_mon = g_date_get_month(&gdate) - 1; - tm.tm_year = g_date_get_year(&gdate) - 1900; + sscanf(convostart, "%*s %s %d %d:%d:%d %d", + month, &tm.tm_mday, &tm.tm_hour, &tm.tm_min, &tm.tm_sec, &tm.tm_year); + /* Ugly hack, in case current locale is not English */ + if (strcmp(month, "Jan") == 0) { + tm.tm_mon= 0; + } else if (strcmp(month, "Feb") == 0) { + tm.tm_mon = 1; + } else if (strcmp(month, "Mar") == 0) { + tm.tm_mon = 2; + } else if (strcmp(month, "Apr") == 0) { + tm.tm_mon = 3; + } else if (strcmp(month, "May") == 0) { + tm.tm_mon = 4; + } else if (strcmp(month, "Jun") == 0) { + tm.tm_mon = 5; + } else if (strcmp(month, "Jul") == 0) { + tm.tm_mon = 6; + } else if (strcmp(month, "Aug") == 0) { + tm.tm_mon = 7; + } else if (strcmp(month, "Sep") == 0) { + tm.tm_mon = 8; + } else if (strcmp(month, "Oct") == 0) { + tm.tm_mon = 9; + } else if (strcmp(month, "Nov") == 0) { + tm.tm_mon = 10; + } else if (strcmp(month, "Dec") == 0) { + tm.tm_mon = 11; + } + tm.tm_year -= 1900; log->time = mktime(&tm); - g_free(date); - } }