From 07ed7fea103ee7f507fb2e49cdd6d983fe54c7b0 Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Wed, 8 Jul 2009 00:52:25 +0000 Subject: [soc2009/i18n] formatting system in development git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/i18n-improvements@11204 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/regressiontests/i18n/tests.py | 59 ++++++++++++++++++++++++++++++++++++- 1 file changed, 58 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py index dc875c6a31..a67b84712d 100644 --- a/tests/regressiontests/i18n/tests.py +++ b/tests/regressiontests/i18n/tests.py @@ -65,13 +65,70 @@ status. >>> print s Password ->>> from django.utils.formats import getformat +Localization of dates and numbers + +>>> import datetime +>>> import decimal +>>> from django.utils.formats import getformat, date_format, number_format, localize + +>>> n = decimal.Decimal('66666.666') +>>> d = datetime.date(2009, 7, 6) +>>> dt = datetime.datetime(2009, 7, 6, 20, 50) + +Locale independent + +>>> number_format(n, decimal_sep='.', decimal_pos=2, grouping=3, thousand_sep=',') +'66,666.66' +>>> number_format(n, decimal_sep='A', decimal_pos=1, grouping=1, thousand_sep='B') +'6B6B6B6B6BA6' + +English locale + >>> activate('en') >>> getformat('DATE_FORMAT') 'N j, Y' +>>> getformat('FIRST_DAY_OF_WEEK') +0 +>>> getformat('DECIMAL_SEPARATOR') +'.' +>>> date_format(d) +'July 6, 2009' +>>> date_format(d, 'YEAR_MONTH_FORMAT') +'July 2009' +>>> date_format(d, 'SHORT_DATETIME_FORMAT') +'07/06/2009 8:50 p.m.' +>>> localize('No localizable') +'No localizable' +>>> localize(n) +'66666.666' +>>> localize(d) +'July 6, 2009' +>>> localize(dt) +'July 6, 2009, 8:50 p.m.' + +Catalan locale + >>> activate('ca') >>> getformat('DATE_FORMAT') 'j \de N \de Y' +>>> getformat('FIRST_DAY_OF_WEEK') +1 +>>> getformat('DECIMAL_SEPARATOR') +',' +>>> date_format(d) +'6 de juliol de 2009' +>>> date_format(d, 'YEAR_MONTH_FORMAT') +'juliol de 2009' +>>> date_format(d, 'SHORT_DATETIME_FORMAT') +'06/07/2009 20:50' +>>> localize('No localizable') +'No localizable' +>>> localize(n) +'66.666,666' +>>> localize(d) +'6 de juliol de 2009' +>>> localize(dt) +'6 de juliol de 2009 a les 20:50' """ -- cgit v1.3