summaryrefslogtreecommitdiff
path: root/tests/regressiontests/dateformat/tests.py
diff options
context:
space:
mode:
authorDerek Anderson <public@kered.org>2006-10-26 19:09:51 +0000
committerDerek Anderson <public@kered.org>2006-10-26 19:09:51 +0000
commit42851d90dadbf62f5d342ce5c4f496ba1eeba987 (patch)
treea5d0e5c178afb2d7dbb7bf5ab37db9ced42f4b52 /tests/regressiontests/dateformat/tests.py
parent450889c9a6f7da3c2fce77a0ccf4c4cea9e29710 (diff)
committing to schema-evolution
merge from HEAD git-svn-id: http://code.djangoproject.com/svn/django/branches/schema-evolution@3937 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests/regressiontests/dateformat/tests.py')
-rw-r--r--tests/regressiontests/dateformat/tests.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/tests/regressiontests/dateformat/tests.py b/tests/regressiontests/dateformat/tests.py
new file mode 100644
index 0000000000..6e28759a92
--- /dev/null
+++ b/tests/regressiontests/dateformat/tests.py
@@ -0,0 +1,84 @@
+r"""
+>>> format(my_birthday, '')
+''
+>>> format(my_birthday, 'a')
+'p.m.'
+>>> format(my_birthday, 'A')
+'PM'
+>>> format(my_birthday, 'd')
+'08'
+>>> format(my_birthday, 'j')
+'8'
+>>> format(my_birthday, 'l')
+'Sunday'
+>>> format(my_birthday, 'L')
+'False'
+>>> format(my_birthday, 'm')
+'07'
+>>> format(my_birthday, 'M')
+'Jul'
+>>> format(my_birthday, 'n')
+'7'
+>>> format(my_birthday, 'N')
+'July'
+>>> no_tz or format(my_birthday, 'O') == '+0100'
+True
+>>> format(my_birthday, 'P')
+'10 p.m.'
+>>> no_tz or format(my_birthday, 'r') == 'Sun, 8 Jul 1979 22:00:00 +0100'
+True
+>>> format(my_birthday, 's')
+'00'
+>>> format(my_birthday, 'S')
+'th'
+>>> format(my_birthday, 't')
+'31'
+>>> no_tz or format(my_birthday, 'T') == 'CET'
+True
+>>> no_tz or format(my_birthday, 'U') == '300531600'
+True
+>>> format(my_birthday, 'w')
+'0'
+>>> format(my_birthday, 'W')
+'27'
+>>> format(my_birthday, 'y')
+'79'
+>>> format(my_birthday, 'Y')
+'1979'
+>>> format(my_birthday, 'z')
+'189'
+>>> no_tz or format(my_birthday, 'Z') == '3600'
+True
+
+>>> no_tz or format(summertime, 'I') == '1'
+True
+>>> no_tz or format(summertime, 'O') == '+0200'
+True
+>>> no_tz or format(wintertime, 'I') == '0'
+True
+>>> no_tz or format(wintertime, 'O') == '+0100'
+True
+
+>>> format(my_birthday, r'Y z \C\E\T')
+'1979 189 CET'
+
+>>> format(my_birthday, r'jS o\f F')
+'8th of July'
+"""
+
+from django.utils import dateformat, translation
+import datetime, os, time
+
+format = dateformat.format
+os.environ['TZ'] = 'Europe/Copenhagen'
+translation.activate('en-us')
+
+try:
+ time.tzset()
+ no_tz = False
+except AttributeError:
+ no_tz = True
+
+my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
+summertime = datetime.datetime(2005, 10, 30, 1, 00)
+wintertime = datetime.datetime(2005, 10, 30, 4, 00)