mirror of
https://github.com/django/django.git
synced 2025-07-04 17:59:13 +00:00
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
This commit is contained in:
parent
1d90cbd758
commit
99b7f9c185
@ -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)
|
||||
|
@ -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'):
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user