summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarc Garcia <garcia.marc@gmail.com>2009-07-08 00:52:25 +0000
committerMarc Garcia <garcia.marc@gmail.com>2009-07-08 00:52:25 +0000
commit07ed7fea103ee7f507fb2e49cdd6d983fe54c7b0 (patch)
treeb2a05285d0f10c466d5da7040c44ac424d72d67b /tests
parent5b616f27c67f087b9f93f10804b175dee4c46839 (diff)
[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
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/i18n/tests.py59
1 files changed, 58 insertions, 1 deletions
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'
"""