2006-05-02 09:31:56 +08:00
|
|
|
r"""
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, '')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u''
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'a')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'p.m.'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'A')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'PM'
|
2006-05-02 09:31:56 +08:00
|
|
|
>>> format(my_birthday, 'd')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'08'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'j')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'8'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'l')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'Sunday'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'L')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'False'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'm')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'07'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'M')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'Jul'
|
2007-03-01 00:18:55 +08:00
|
|
|
>>> format(my_birthday, 'b')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'jul'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'n')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'7'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'N')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'July'
|
2006-09-26 21:38:19 +08:00
|
|
|
>>> no_tz or format(my_birthday, 'O') == '+0100'
|
|
|
|
True
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'P')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'10 p.m.'
|
2006-09-26 21:38:19 +08:00
|
|
|
>>> no_tz or format(my_birthday, 'r') == 'Sun, 8 Jul 1979 22:00:00 +0100'
|
|
|
|
True
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 's')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'00'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'S')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'th'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 't')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'31'
|
2006-09-26 21:38:19 +08:00
|
|
|
>>> no_tz or format(my_birthday, 'T') == 'CET'
|
|
|
|
True
|
2009-05-08 21:39:37 +08:00
|
|
|
>>> no_tz or format(my_birthday, 'U') == '300315600'
|
2006-09-26 21:38:19 +08:00
|
|
|
True
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'w')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'0'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'W')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'27'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'y')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'79'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'Y')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'1979'
|
2005-10-23 05:37:59 +08:00
|
|
|
>>> format(my_birthday, 'z')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'189'
|
2006-09-26 21:38:19 +08:00
|
|
|
>>> no_tz or format(my_birthday, 'Z') == '3600'
|
|
|
|
True
|
2005-10-23 05:37:59 +08:00
|
|
|
|
2006-09-26 21:38:19 +08:00
|
|
|
>>> 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
|
2005-10-23 05:37:59 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
>>> format(my_birthday, r'Y z \C\E\T')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'1979 189 CET'
|
2006-05-02 09:31:56 +08:00
|
|
|
|
|
|
|
>>> format(my_birthday, r'jS o\f F')
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
u'8th of July'
|
2007-11-30 03:39:46 +08:00
|
|
|
|
|
|
|
>>> format(the_future, r'Y')
|
|
|
|
u'2100'
|
2005-10-23 05:37:59 +08:00
|
|
|
"""
|
|
|
|
|
2005-11-10 04:36:23 +08:00
|
|
|
from django.utils import dateformat, translation
|
2005-10-23 05:37:59 +08:00
|
|
|
import datetime, os, time
|
|
|
|
|
2005-11-10 04:36:23 +08:00
|
|
|
format = dateformat.format
|
2005-10-23 05:37:59 +08:00
|
|
|
os.environ['TZ'] = 'Europe/Copenhagen'
|
2005-11-10 04:36:23 +08:00
|
|
|
translation.activate('en-us')
|
|
|
|
|
2006-09-26 21:38:19 +08:00
|
|
|
try:
|
|
|
|
time.tzset()
|
|
|
|
no_tz = False
|
|
|
|
except AttributeError:
|
|
|
|
no_tz = True
|
2005-10-23 05:37:59 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
|
2005-10-23 05:37:59 +08:00
|
|
|
summertime = datetime.datetime(2005, 10, 30, 1, 00)
|
|
|
|
wintertime = datetime.datetime(2005, 10, 30, 4, 00)
|
2007-11-30 03:39:46 +08:00
|
|
|
the_future = datetime.datetime(2100, 10, 25, 0, 00)
|