comparison plugins/timestamp_format.c @ 13104:e1e5462b7d81

[gaim-migrate @ 15466] Rework lots of date parsing. I either introduced a whole lot of bugs, or I've made sure all dates are localized properly now. Only time will tell which it is... ;) committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Thu, 02 Feb 2006 19:50:51 +0000
parents b553326bc468
children c73c7dd0721f
comparison
equal deleted inserted replaced
13103:a6811e213977 13104:e1e5462b7d81
1 #include "internal.h" 1 #include "internal.h"
2 2
3 #include "debug.h" 3 #include "debug.h"
4 #include "log.h" 4 #include "log.h"
5 #include "plugin.h" 5 #include "plugin.h"
6 #include "util.h"
6 #include "version.h" 7 #include "version.h"
7 8
8 #include "gtkconv.h" 9 #include "gtkconv.h"
9 #include "gtkplugin.h" 10 #include "gtkplugin.h"
10 11
53 static char *timestamp_cb_common(GaimConversation *conv, 54 static char *timestamp_cb_common(GaimConversation *conv,
54 const struct tm *tm, 55 const struct tm *tm,
55 gboolean force, 56 gboolean force,
56 const char *dates) 57 const char *dates)
57 { 58 {
58 char buf[64];
59
60 g_return_val_if_fail(conv != NULL, NULL); 59 g_return_val_if_fail(conv != NULL, NULL);
61 g_return_val_if_fail(tm != NULL, NULL); 60 g_return_val_if_fail(tm != NULL, NULL);
62 g_return_val_if_fail(dates != NULL, NULL); 61 g_return_val_if_fail(dates != NULL, NULL);
63 62
64 if (!strcmp(dates, "always") || 63 if (!strcmp(dates, "always") ||
65 (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && 64 (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT &&
66 !strcmp(dates, "chats")) || 65 !strcmp(dates, "chats")) ||
67 (time(NULL) > (mktime((struct tm *)tm) + 20*60))) 66 (time(NULL) > (mktime((struct tm *)tm) + 20*60)))
68 { 67 {
69 if (force) 68 if (force)
70 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm); 69 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm));
71 else 70 else
72 strftime(buf, sizeof(buf), "%x %X", tm); 71 return g_strdup(gaim_date_format_long(tm));
73
74 return g_strdup(buf);
75 } 72 }
76 73
77 if (force) 74 if (force)
78 { 75 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm));
79 strftime(buf, sizeof(buf), "%H:%M:%S", tm);
80 return g_strdup(buf);
81 }
82 76
83 return NULL; 77 return NULL;
84 } 78 }
85 79
86 static char *conversation_timestamp_cb(GaimConversation *conv, 80 static char *conversation_timestamp_cb(GaimConversation *conv,
109 g_return_val_if_fail(tm != NULL, NULL); 103 g_return_val_if_fail(tm != NULL, NULL);
110 104
111 if (log->type == GAIM_LOG_SYSTEM) 105 if (log->type == GAIM_LOG_SYSTEM)
112 { 106 {
113 if (force) 107 if (force)
114 { 108 return g_strdup(gaim_utf8_strftime("%Y-%m-%d %H:%M:%S", tm));
115 char buf[64];
116 strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm);
117 return g_strdup(buf);
118 }
119 else 109 else
120 return NULL; 110 return NULL;
121 } 111 }
122 112
123 return timestamp_cb_common(log->conv, tm, force, dates); 113 return timestamp_cb_common(log->conv, tm, force, dates);