diff --git a/django/db/backends/util.py b/django/db/backends/util.py
index f9c07a9..0b7f377 100644
a
|
b
|
class CursorDebugWrapper(object):
|
50 | 50 | ############################################### |
51 | 51 | |
52 | 52 | def typecast_date(s): |
53 | | return s and datetime.date(*map(int, s.split('-'))) or None # returns None if s is null |
| 53 | if not s: |
| 54 | return None |
| 55 | dates = map(int, s.split('-')) |
| 56 | if 0 in dates: |
| 57 | return None |
| 58 | return s and datetime.date(*dates) or None # returns None if s is null |
54 | 59 | |
55 | 60 | def typecast_time(s): # does NOT store time zone information |
56 | 61 | if not s: return None |
… |
… |
def typecast_timestamp(s): # does NOT store time zone information
|
77 | 82 | tz = '+' + tz |
78 | 83 | else: |
79 | 84 | tz = '' |
80 | | dates = d.split('-') |
| 85 | dates = map(int, d.split('-')) |
81 | 86 | times = t.split(':') |
82 | 87 | seconds = times[2] |
| 88 | if 0 in dates: |
| 89 | return None |
83 | 90 | if '.' in seconds: # check whether seconds have a fractional part |
84 | 91 | seconds, microseconds = seconds.split('.') |
85 | 92 | else: |
diff --git a/tests/regressiontests/db_typecasts/tests.py b/tests/regressiontests/db_typecasts/tests.py
index f4b77fe..eb653b7 100644
a
|
b
|
TEST_CASES = {
|
7 | 7 | 'typecast_date': ( |
8 | 8 | ('', None), |
9 | 9 | (None, None), |
| 10 | ('0000-00-00', None), |
10 | 11 | ('2005-08-11', datetime.date(2005, 8, 11)), |
11 | 12 | ('1990-01-01', datetime.date(1990, 1, 1)), |
12 | 13 | ), |
… |
… |
TEST_CASES = {
|
28 | 29 | 'typecast_timestamp': ( |
29 | 30 | ('', None), |
30 | 31 | (None, None), |
| 32 | ('0000-00-00 0:00:00', None), |
31 | 33 | ('2005-08-11 0:00:00', datetime.datetime(2005, 8, 11)), |
32 | 34 | ('2005-08-11 0:30:00', datetime.datetime(2005, 8, 11, 0, 30)), |
33 | 35 | ('2005-08-11 8:50:30', datetime.datetime(2005, 8, 11, 8, 50, 30)), |