Ticket #16906: 16906.patch
File 16906.patch, 7.4 KB (added by , 13 years ago) |
---|
-
django/db/models/fields/__init__.py
16 16 from django.utils.text import capfirst 17 17 from django.utils.translation import ugettext_lazy as _ 18 18 from django.utils.encoding import smart_unicode, force_unicode, smart_str 19 from django.utils import datetime_safe20 19 from django.utils.ipv6 import clean_ipv6_address 21 20 22 21 class NOT_PROVIDED: … … 669 668 if val is None: 670 669 data = '' 671 670 else: 672 data = datetime_safe.new_date(val).strftime("%Y-%m-%d")671 data = str(val) 673 672 return data 674 673 675 674 def formfield(self, **kwargs): … … 743 742 if val is None: 744 743 data = '' 745 744 else: 746 d = datetime_safe.new_datetime(val) 747 data = d.strftime('%Y-%m-%d %H:%M:%S') 745 data = str(val.replace(microsecond=0, tzinfo=None)) 748 746 return data 749 747 750 748 def formfield(self, **kwargs): -
django/db/backends/sqlite3/base.py
320 320 dt = dt - delta 321 321 except (ValueError, TypeError): 322 322 return None 323 # typecast_timestamp returns a date or a datetime without timezone. 324 # It will be formatted as "%Y-%m-%d" or "%Y-%m-%d %H:%M:%S[.%f]" 325 return str(dt) 323 326 324 if isinstance(dt, datetime.datetime):325 rv = dt.strftime("%Y-%m-%d %H:%M:%S")326 if dt.microsecond:327 rv = "%s.%0.6d" % (rv, dt.microsecond)328 else:329 rv = dt.strftime("%Y-%m-%d")330 return rv331 332 327 def _sqlite_regexp(re_pattern, re_string): 333 328 try: 334 329 return bool(re.search(re_pattern, re_string)) -
django/db/backends/__init__.py
9 9 from django.db import DEFAULT_DB_ALIAS 10 10 from django.db.backends import util 11 11 from django.db.transaction import TransactionManagementError 12 from django.utils import datetime_safe13 12 from django.utils.importlib import import_module 14 13 15 14 … … 718 717 """ 719 718 if value is None: 720 719 return None 721 return datetime_safe.new_date(value).strftime('%Y-%m-%d')720 return unicode(value) 722 721 723 722 def value_to_db_datetime(self, value): 724 723 """ … … 731 730 732 731 def value_to_db_time(self, value): 733 732 """ 734 Transform a datetime value to an object compatible with what is expected733 Transform a time value to an object compatible with what is expected 735 734 by the backend driver for time columns. 736 735 """ 737 736 if value is None: -
django/contrib/sitemaps/tests/basic.py
67 67 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 68 68 <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> 69 69 </urlset> 70 """ % (self.base_url, date.today() .strftime('%Y-%m-%d')))70 """ % (self.base_url, date.today())) 71 71 72 72 def test_simple_custom_sitemap(self): 73 73 "A simple sitemap can be rendered with a custom template" … … 79 79 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 80 80 <url><loc>%s/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> 81 81 </urlset> 82 """ % (self.base_url, date.today() .strftime('%Y-%m-%d')))82 """ % (self.base_url, date.today())) 83 83 84 84 @skipUnless(settings.USE_I18N, "Internationalization is not enabled") 85 85 def test_localized_priority(self): … … 93 93 # haven't been rendered in localized format 94 94 response = self.client.get('/simple/sitemap.xml') 95 95 self.assertContains(response, '<priority>0.5</priority>') 96 self.assertContains(response, '<lastmod>%s</lastmod>' % date.today() .strftime('%Y-%m-%d'))96 self.assertContains(response, '<lastmod>%s</lastmod>' % date.today()) 97 97 deactivate() 98 98 99 99 def test_generic_sitemap(self): … … 152 152 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 153 153 <url><loc>http://testserver/location/</loc><lastmod>%s</lastmod><changefreq>never</changefreq><priority>0.5</priority></url> 154 154 </urlset> 155 """ % date.today() .strftime('%Y-%m-%d'))155 """ % date.today()) 156 156 157 157 @skipUnless("django.contrib.sites" in settings.INSTALLED_APPS, "django.contrib.sites app not installed.") 158 158 def test_sitemap_get_urls_no_site_1(self): -
django/contrib/admin/filters.py
281 281 282 282 today = datetime.date.today() 283 283 one_week_ago = today - datetime.timedelta(days=7) 284 today_str = (isinstance(self.field, models.DateTimeField)285 and today.strftime('%Y-%m-%d 23:59:59')286 or today.strftime('%Y-%m-%d'))284 today_str = str(today) 285 if isinstance(self.field, models.DateTimeField): 286 today_str += ' 23:59:59' 287 287 288 288 self.lookup_kwarg_year = '%s__year' % self.field_path 289 289 self.lookup_kwarg_month = '%s__month' % self.field_path … … 299 299 self.lookup_kwarg_day: str(today.day), 300 300 }), 301 301 (_('Past 7 days'), { 302 self.lookup_kwarg_past_7_days_gte: one_week_ago.strftime('%Y-%m-%d'),302 self.lookup_kwarg_past_7_days_gte: str(one_week_ago), 303 303 self.lookup_kwarg_past_7_days_lte: today_str, 304 304 }), 305 305 (_('This month'), { -
tests/regressiontests/admin_filters/tests.py
186 186 self.assertEqual(choice['query_string'], '?date_registered__year=%s' 187 187 % (self.today.year)) 188 188 189 request = self.request_factory.get('/', {'date_registered__gte': s elf.one_week_ago.strftime('%Y-%m-%d'),190 'date_registered__lte': s elf.today.strftime('%Y-%m-%d')})189 request = self.request_factory.get('/', {'date_registered__gte': str(self.one_week_ago), 190 'date_registered__lte': str(self.today)}) 191 191 changelist = self.get_changelist(request, Book, modeladmin) 192 192 193 193 # Make sure the correct queryset is returned … … 201 201 self.assertEqual(choice['selected'], True) 202 202 self.assertEqual(choice['query_string'], '?date_registered__gte=%s' 203 203 '&date_registered__lte=%s' 204 % (s elf.one_week_ago.strftime('%Y-%m-%d'), self.today.strftime('%Y-%m-%d')))204 % (str(self.one_week_ago), str(self.today))) 205 205 206 206 def test_allvaluesfieldlistfilter(self): 207 207 modeladmin = BookAdmin(Book, site)