﻿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
3306	[patch] tzinfo raises OverflowError for years out of time.mktime supported range	ymasuda <ymasuda@…>	nobody	"'''Summary'''

In django.utils.tzinfo, LocalTimezone._isdst() is calling time.time() to indicate DST status of the timezone.
This causes OverflowError if you put a DateTimeField and list it in Admin.list_display, then save instance with
far future date (namely beyond 2038) and display it in admin site's changelist.

'''Symptom with example'''

Assume 'sandbox.foo' application has following model:
{{{
class Bar(models.Model):
    date = models.DateTimeField()
    class Admin:
        list_display = ('date',)
}}}

And an user create Bar instance of 3000/01/01:
{{{
>>> from sandbox.foo.models import Bar
>>> from datetime import datetime
>>> b = Bar(date=datetime(3000, 1, 1)) 
>>> b.save()
>>>
}}}

The instance is saved silently (even in admin's Create New Bar view), but your changelist view
(http://yourdomain/admin/foo/bar/) will raise OverflowError:
{{{
OverflowError at /admin/foo/bar/
mktime argument out of range

Request Method:	GET
Request URL:	http://localhost:8000/admin/foo/bar/
Exception Type:	OverflowError
Exception Value:	mktime argument out of range
Exception Location:	/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/django/utils/tzinfo.py in _isdst, line 51
}}}

'''Proposed resolution'''

The attached patch includes modification in LocalTimezone._isdst() so that the years out of
mktime-supported range (1970-2037) will be clipped as 1970 or 2037.
Applying this patch will allow user to specify years in range (1900-9999).

'''Note'''

As an alternative resolution, Date(Time)Field may validate its value to reject years out of (1970-2037)."	defect	closed	Core (Other)		normal	duplicate			Design decision needed	1	0	0	0	0	0
