﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3418	MSSQL and OverflowError for django/utils/tzinfo.py	Jaroslaw Zabiello	nobody	"{{{
Exception Type:  	OverflowError
Exception Value: 	mktime argument out of range
Exception Location: 	C:\opt\Python25\lib\site-packages\django\utils\tzinfo.py in _isdst, line 50
}}}

This kind of errors appears when you work with SQL Server (or transfered data from MSSQL to MySQL). SQL Server converts NULLs in its datetime field into year 1900! And this raise exception OverflowError with message ""mktime argument out of range"" for pythonic function time.mktime() used in utils/tzinfo.py at line 50:

{{{
def _isdst(self, dt):
    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
}}}

This is monkey patched code which solves this problem:

{{{
def _isdst(self, dt):
    year = dt.year
    if year == 1900: # or < 1970
        year = 1970
    tt = (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
}}}

Used Django SVN rev.4455, WinXP Pro."		closed	Tools	dev		invalid	ado_mssql datetime overflow		Design decision needed	1	0	0	1	0	0
