summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-04-17 19:19:38 +0000
committerBoulder Sprinters <boulder-sprinters@djangoproject.com>2007-04-17 19:19:38 +0000
commit99b7f9c1855f82d92fe686f246c4c1241fee1de1 (patch)
treeda2d18ff5402a0201b96348668e54de1e16d46ca
parent1d90cbd758d268b05a32c14ff3054b75e436e0e7 (diff)
boulder-oracle-sprint: Non-functional changes to bring the branch closer to the current state of the trunk.
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@5021 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/db/models/fields/__init__.py34
-rw-r--r--django/db/models/query.py4
-rw-r--r--django/utils/tzinfo.py2
3 files changed, 20 insertions, 20 deletions
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 9fe6037185..d7cc279608 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -494,15 +494,12 @@ class DateField(Field):
def get_db_prep_save(self, value):
# Casts dates into string format for entry into database.
- if settings.DATABASE_ENGINE != 'oracle':
- if isinstance(value, datetime.datetime):
- value = value.date().strftime('%Y-%m-%d')
- elif isinstance(value, datetime.date):
- value = value.strftime('%Y-%m-%d')
- else:
+ if settings.DATABASE_ENGINE == 'oracle':
# cx_Oracle needs a conversion to datetime.datetime instead.
if isinstance(value, datetime.date):
value = datetime.datetime.combine(value, datetime.time())
+ elif value is not None:
+ value = value.strftime('%Y-%m-%d')
return Field.get_db_prep_save(self, value)
def get_manipulator_field_objs(self):
@@ -825,11 +822,14 @@ class TimeField(Field):
Field.__init__(self, verbose_name, name, **kwargs)
def get_db_prep_lookup(self, lookup_type, value):
- def prep(value):
- if settings.DATABASE_ENGINE == 'oracle' and isinstance(value, datetime.time):
- # Oracle requires a date in order to parse.
- value = datetime.datetime.combine(datetime.date(1900, 1, 1), value)
- return str(value)
+ if settings.DATABASE_ENGINE == 'oracle':
+ # Oracle requires a date in order to parse.
+ def prep(value):
+ if isinstance(value, datetime.time):
+ value = datetime.datetime.combine(datetime.date(1900, 1, 1), value)
+ return str(value)
+ else:
+ prep = str
if lookup_type == 'range':
value = [prep(v) for v in value]
else:
@@ -849,15 +849,13 @@ class TimeField(Field):
if value is not None:
# MySQL will throw a warning if microseconds are given, because it
# doesn't support microseconds.
- if settings.DATABASE_ENGINE == 'mysql' and hasattr(value, 'microsecond'):
+ if settings.DATABASE_ENGINE in ('mysql', 'oracle') and hasattr(value, 'microsecond'):
value = value.replace(microsecond=0)
- value = str(value)
- elif settings.DATABASE_ENGINE == 'oracle':
- if hasattr(value, 'microsecond'):
- value = value.replace(microsecond=0)
- # cx_Oracle expects a datetime.datetime to persist into TIMESTAMP field.
+ if settings.DATABASE_ENGINE == 'oracle':
+ # cx_Oracle expects a datetime.datetime to persist into TIMESTAMP field.
+ if isinstance(value, datetime.time):
value = datetime.datetime(1900, 1, 1, value.hour, value.minute, value.second)
- else:
+ elif isinstance(value, basestring):
value = datetime.datetime(*(time.strptime(value, '%H:%M:%S')[:6]))
else:
value = str(value)
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 44edb1cd22..16c3df5d08 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -5,7 +5,9 @@ from django.db.models import signals
from django.dispatch import dispatcher
from django.utils.datastructures import SortedDict
from django.conf import settings
-import datetime, operator, re
+import datetime
+import operator
+import re
# For Python 2.3
if not hasattr(__builtins__, 'set'):
diff --git a/django/utils/tzinfo.py b/django/utils/tzinfo.py
index abfe86cc7c..cc9f028e91 100644
--- a/django/utils/tzinfo.py
+++ b/django/utils/tzinfo.py
@@ -46,7 +46,7 @@ class LocalTimezone(tzinfo):
return time.tzname[self._isdst(dt)]
def _isdst(self, dt):
- tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, 0, 0, -1)
+ tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.weekday(), 0, -1)
stamp = time.mktime(tt)
tt = time.localtime(stamp)
return tt.tm_isdst > 0