[Nautilus-list] [PATCH] correct dates in nautilus



This patch for eel makes all dates displayed correctly even in non-ascii
locales. May I commit?

-- 
Gediminas Paulauskas
Kaunas, Lithuania
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/eel/ChangeLog,v
retrieving revision 1.256
diff -u -p -r1.256 ChangeLog
--- ChangeLog	2002/01/19 08:02:27	1.256
+++ ChangeLog	2002/01/19 17:35:32
@@ -1,3 +1,9 @@
+2002-01-19  Gediminas Paulauskas <menesis delfi lt>
+
+	* eel/eel-glib-extensions.c: (eel_strdup_strftime):
+	Convert format string into locale encoding at start, and convert back
+	into utf-8 the result. 
+
 2002-01-19  Darin Adler  <darin bentspoon com>
 
 	* test/test-eel-gtk-style.c: (style_get_color), (style_get_gc):
Index: eel/eel-glib-extensions.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-glib-extensions.c,v
retrieving revision 1.13
diff -u -p -r1.13 eel-glib-extensions.c
--- eel/eel-glib-extensions.c	2002/01/19 00:19:29	1.13
+++ eel/eel-glib-extensions.c	2002/01/19 17:35:42
@@ -165,14 +165,16 @@ char *
 eel_strdup_strftime (const char *format, struct tm *time_pieces)
 {
 	GString *string;
-	const char *remainder, *percent;
+	char *remainder, *percent;
 	char code[3], buffer[512];
 	char *piece, *result;
 	size_t string_length;
 	gboolean strip_leading_zeros, turn_leading_zeros_to_spaces;
 
 	string = g_string_new ("");
-	remainder = format;
+	/* Format could be translated, and contain UTF-8 chars,
+	 * so convert to locale encoding which strftime uses */
+	remainder = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
 
 	/* Walk from % character to % character. */
 	for (;;) {
@@ -262,10 +264,12 @@ eel_strdup_strftime (const char *format,
 		/* Add this piece. */
 		g_string_append (string, piece);
 	}
+	
+	g_free (remainder);
 
-	/* Extract the string. */
-	result = string->str;
-	g_string_free (string, FALSE);
+	/* Convert the string back into utf-8. */
+	result = g_locale_to_utf8 (string->str, -1, NULL, NULL, NULL);
+	g_string_free (string, TRUE);
 	return result;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]