g_date_time_format: improve support for alt digits

Improve a few situations where g_date_time_format() was getting the
padding wrong when displaying alt digits (eg: Arabic numerals) for
formatting time.

We now depend on nl_langinfo (_NL_CTYPE_OUTDIGITn_WC) to do the
conversion, which is very likely glibc-specific, but our previous method
relied on a glibc-specific printf() feature, so no harm done there.

Add a configure check for nl_langinfo (_NL_CTYPE_OUTDIGITn_WC).

Uncomment a few testcases that were failing previously.

https://bugzilla.gnome.org/show_bug.cgi?id=658107
This commit is contained in:
Ryan Lortie
2011-09-03 20:12:53 -04:00
parent 4a371c2ce5
commit 2d7051e3a3
3 changed files with 114 additions and 92 deletions

View File

@@ -896,17 +896,14 @@ test_modifiers (void)
setlocale (LC_ALL, "fa_IR.utf-8");
if (strstr (setlocale (LC_ALL, NULL), "fa_IR") != NULL)
{
TEST_PRINTF_TIME (23, 0, 0, "%OH", "\333\262\333\263");
TEST_PRINTF_TIME (23, 0, 0, "%OI", "\333\261\333\261");
TEST_PRINTF_TIME (23, 0, 0, "%OM", "\333\260");
TEST_PRINTF_TIME (23, 0, 0, "%OH", "\333\262\333\263"); /* '23' */
TEST_PRINTF_TIME (23, 0, 0, "%OI", "\333\261\333\261"); /* '11' */
TEST_PRINTF_TIME (23, 0, 0, "%OM", "\333\260\333\260"); /* '00' */
TEST_PRINTF_DATE (2011, 7, 1, "%Om", "\333\267");
TEST_PRINTF_DATE (2011, 7, 1, "%-Om", "\333\267");
/* These do not currently work as expected, since glib's printf
counts arabic digits as two characters for some reason
TEST_PRINTF_DATE (2011, 7, 1, "%0Om", "0\333\267");
TEST_PRINTF_DATE (2011, 7, 1, "%_Om", " \333\267");
*/
TEST_PRINTF_DATE (2011, 7, 1, "%Om", "\333\260\333\267"); /* '07' */
TEST_PRINTF_DATE (2011, 7, 1, "%0Om", "\333\260\333\267"); /* '07' */
TEST_PRINTF_DATE (2011, 7, 1, "%-Om", "\333\267"); /* '7' */
TEST_PRINTF_DATE (2011, 7, 1, "%_Om", " \333\267"); /* ' 7' */
}
else
g_test_message ("locale fa_IR not available, skipping O modifier tests");