Ticket #13621: ticket13621-alternative2.diff
File ticket13621-alternative2.diff, 2.3 KB (added by , 14 years ago) |
---|
-
django/forms/fields.py
337 337 return value.date() 338 338 if isinstance(value, datetime.date): 339 339 return value 340 for format in self.input_formats or formats.get_format('DATE_INPUT_FORMATS' ):340 for format in self.input_formats or formats.get_format('DATE_INPUT_FORMATS', self.localize): 341 341 try: 342 342 return datetime.date(*time.strptime(value, format)[:3]) 343 343 except ValueError: … … 363 363 return None 364 364 if isinstance(value, datetime.time): 365 365 return value 366 for format in self.input_formats or formats.get_format('TIME_INPUT_FORMATS' ):366 for format in self.input_formats or formats.get_format('TIME_INPUT_FORMATS', self.localize): 367 367 try: 368 368 return datetime.time(*time.strptime(value, format)[3:6]) 369 369 except ValueError: … … 397 397 if len(value) != 2: 398 398 raise ValidationError(self.error_messages['invalid']) 399 399 value = '%s %s' % tuple(value) 400 for format in self.input_formats or formats.get_format('DATETIME_INPUT_FORMATS' ):400 for format in self.input_formats or formats.get_format('DATETIME_INPUT_FORMATS', self.localize): 401 401 try: 402 402 return datetime.datetime(*time.strptime(value, format)[:6]) 403 403 except ValueError: -
django/utils/formats.py
34 34 modules.reverse() 35 35 return modules 36 36 37 def get_format(format_type ):37 def get_format(format_type, L10N=True): 38 38 """ 39 39 For a specific format type, returns the format for the current 40 40 language (locale), defaults to the format in the settings. 41 41 format_type is the name of the format, e.g. 'DATE_FORMAT' 42 42 """ 43 43 format_type = smart_str(format_type) 44 if settings.USE_L10N :44 if settings.USE_L10N and L10N: 45 45 for module in get_format_modules(): 46 46 try: 47 47 return getattr(module, format_type)