mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #12472 - Correctly show TimeFields values when using locale-aware formatting. Thanks to Ramiro Morales for providing the patch.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12050 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -15,10 +15,10 @@ except ImportError: | ||||
|  | ||||
| from django.template import Variable, Library | ||||
| from django.conf import settings | ||||
| from django.utils import formats | ||||
| from django.utils.translation import ugettext, ungettext | ||||
| from django.utils.encoding import force_unicode, iri_to_uri | ||||
| from django.utils.safestring import mark_safe, SafeData | ||||
| from django.utils.formats import date_format, number_format | ||||
|  | ||||
| register = Library() | ||||
|  | ||||
| @@ -167,14 +167,14 @@ def floatformat(text, arg=-1): | ||||
|         return input_val | ||||
|  | ||||
|     if not m and p < 0: | ||||
|         return mark_safe(number_format(u'%d' % (int(d)), 0)) | ||||
|         return mark_safe(formats.number_format(u'%d' % (int(d)), 0)) | ||||
|  | ||||
|     if p == 0: | ||||
|         exp = Decimal(1) | ||||
|     else: | ||||
|         exp = Decimal('1.0') / (Decimal(10) ** abs(p)) | ||||
|     try: | ||||
|         return mark_safe(number_format(u'%s' % str(d.quantize(exp, ROUND_HALF_UP)), abs(p))) | ||||
|         return mark_safe(formats.number_format(u'%s' % str(d.quantize(exp, ROUND_HALF_UP)), abs(p))) | ||||
|     except InvalidOperation: | ||||
|         return input_val | ||||
| floatformat.is_safe = True | ||||
| @@ -686,7 +686,7 @@ def date(value, arg=None): | ||||
|     if arg is None: | ||||
|         arg = settings.DATE_FORMAT | ||||
|     try: | ||||
|         return date_format(value, arg) | ||||
|         return formats.date_format(value, arg) | ||||
|     except AttributeError: | ||||
|         try: | ||||
|             return format(value, arg) | ||||
| @@ -696,16 +696,16 @@ date.is_safe = False | ||||
|  | ||||
| def time(value, arg=None): | ||||
|     """Formats a time according to the given format.""" | ||||
|     from django.utils.dateformat import time_format | ||||
|     from django.utils import dateformat | ||||
|     if value in (None, u''): | ||||
|         return u'' | ||||
|     if arg is None: | ||||
|         arg = settings.TIME_FORMAT | ||||
|     try: | ||||
|         return date_format(value, arg) | ||||
|         return formats.time_format(value, arg) | ||||
|     except AttributeError: | ||||
|         try: | ||||
|             return time_format(value, arg) | ||||
|             return dateformat.time_format(value, arg) | ||||
|         except AttributeError: | ||||
|             return '' | ||||
| time.is_safe = False | ||||
|   | ||||
		Reference in New Issue
	
	Block a user