Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #6023 -- Fixed daylight savings determination for years beyond …

…2038 on

32-bit systems (modulo the fact that the system timezone libraries might not be
accurate that far out; at least we don't crash now). Thanks, SmileyChris.


git-svn-id: http://code.djangoproject.com/svn/django/trunk@6749 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit f3c15225fc58ae45c6aa71eb5174ff66f3f5e974 1 parent 260f9c5
@malcolmt malcolmt authored
View
8 django/utils/tzinfo.py
@@ -54,6 +54,12 @@ def tzname(self, dt):
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)
+ try:
+ stamp = time.mktime(tt)
+ except OverflowError:
+ # 32 bit systems can't handle dates after Jan 2038, so we fake it
+ # in that case (since we only care about the DST flag here).
+ tt = (2037,) + tt[1:]
+ stamp = time.mktime(tt)
tt = time.localtime(stamp)
return tt.tm_isdst > 0
View
4 tests/regressiontests/dateformat/tests.py
@@ -66,6 +66,9 @@
>>> format(my_birthday, r'jS o\f F')
u'8th of July'
+
+>>> format(the_future, r'Y')
+u'2100'
"""
from django.utils import dateformat, translation
@@ -84,3 +87,4 @@
my_birthday = datetime.datetime(1979, 7, 8, 22, 00)
summertime = datetime.datetime(2005, 10, 30, 1, 00)
wintertime = datetime.datetime(2005, 10, 30, 4, 00)
+the_future = datetime.datetime(2100, 10, 25, 0, 00)
Please sign in to comment.
Something went wrong with that request. Please try again.