libpurple/util.c

changeset 41250
e82d07ed6862
parent 41249
b147a2ac58f0
child 41373
03b5e6d53fa1
equal deleted inserted replaced
41249:b147a2ac58f0 41250:e82d07ed6862
46 } 46 }
47 47
48 /************************************************************************** 48 /**************************************************************************
49 * Date/Time Functions 49 * Date/Time Functions
50 **************************************************************************/ 50 **************************************************************************/
51
52 const char * 51 const char *
53 purple_utf8_strftime(const char *format, const struct tm *tm) 52 purple_date_format_full(const struct tm *tm)
54 { 53 {
55 static char buf[128]; 54 static char buf[128];
56 GDateTime *dt; 55 GDateTime *dt;
57 char *utf8; 56 char *utf8;
58
59 g_return_val_if_fail(format != NULL, NULL);
60 57
61 if (tm == NULL) 58 if (tm == NULL)
62 { 59 {
63 dt = g_date_time_new_now_local(); 60 dt = g_date_time_new_now_local();
64 } else { 61 } else {
65 dt = g_date_time_new_local(tm->tm_year + 1900, tm->tm_mon + 1, 62 dt = g_date_time_new_local(tm->tm_year + 1900, tm->tm_mon + 1,
66 tm->tm_mday, tm->tm_hour, 63 tm->tm_mday, tm->tm_hour,
67 tm->tm_min, tm->tm_sec); 64 tm->tm_min, tm->tm_sec);
68 } 65 }
69 66
70 utf8 = g_date_time_format(dt, format); 67 utf8 = g_date_time_format(dt, "%c");
71 g_date_time_unref(dt); 68 g_date_time_unref(dt);
72 69
73 if (utf8 == NULL) { 70 if (utf8 == NULL) {
74 purple_debug_error("util", 71 purple_debug_error("util",
75 "purple_utf8_strftime(): Formatting failed\n"); 72 "purple_date_format_full(): Formatting failed\n");
76 return ""; 73 return "";
77 } 74 }
78 75
79 g_strlcpy(buf, utf8, sizeof(buf)); 76 g_strlcpy(buf, utf8, sizeof(buf));
80 g_free(utf8); 77 g_free(utf8);
81 return buf; 78 return buf;
82 }
83
84 const char *
85 purple_date_format_full(const struct tm *tm)
86 {
87 return purple_utf8_strftime("%c", tm);
88 } 79 }
89 80
90 /************************************************************************** 81 /**************************************************************************
91 * Path/Filename Functions 82 * Path/Filename Functions
92 **************************************************************************/ 83 **************************************************************************/

mercurial