Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed Python2.4 incompatibility introduced in r13041: datetime.strpti…

…me classmethod was added in 2.5.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@13078 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 7fc25715d6af20e14827c85170fff20f82ded8ab 1 parent 02ffb6f
Karen Tracey authored May 03, 2010

Showing 1 changed file with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. 7  django/forms/extras/widgets.py
7  django/forms/extras/widgets.py
@@ -2,6 +2,7 @@
2 2
 Extra HTML Widget classes
3 3
 """
4 4
 
  5
+import time
5 6
 import datetime
6 7
 import re
7 8
 
@@ -46,7 +47,11 @@ def render(self, name, value, attrs=None):
46 47
                 if settings.USE_L10N:
47 48
                     try:
48 49
                         input_format = get_format('DATE_INPUT_FORMATS')[0]
49  
-                        v = datetime.datetime.strptime(value, input_format)
  50
+                        # Python 2.4 compatibility:
  51
+                        #     v = datetime.datetime.strptime(value, input_format)
  52
+                        # would be clearer, but datetime.strptime was added in 
  53
+                        # Python 2.5
  54
+                        v = datetime.datetime(*(time.strptime(value, input_format)[0:6]))
50 55
                         year_val, month_val, day_val = v.year, v.month, v.day
51 56
                     except ValueError:
52 57
                         pass

0 notes on commit 7fc2571

Please sign in to comment.
Something went wrong with that request. Please try again.