Author: adrian
Date: 2008-07-17 22:45:30 -0500 (Thu, 17 Jul 2008)
New Revision: 7945
Modified:
django/trunk/django/utils/tzinfo.py
Log:
Improved LocalTimezone._isdst() to handle dates before approximately 1901-12-01
(the specific cutoff date is platform-specific). Refs #1443
Modified: django/trunk/django/utils/tzinfo.py
===================================================================
--- django/trunk/django/utils/tzinfo.py 2008-07-17 20:12:21 UTC (rev 7944)
+++ django/trunk/django/utils/tzinfo.py 2008-07-18 03:45:30 UTC (rev 7945)
@@ -60,9 +60,17 @@
tt = (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second,
dt.weekday(), 0, -1)
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).
+ except (OverflowError, ValueError):
+ # 32 bit systems can't handle dates after Jan 2038, and certain
+ # systems can't handle dates before ~1901-12-01:
+ #
+ # >>> time.mktime((1900, 1, 13, 0, 0, 0, 0, 0, 0))
+ # OverflowError: mktime argument out of range
+ # >>> time.mktime((1850, 1, 13, 0, 0, 0, 0, 0, 0))
+ # ValueError: year out of range
+ #
+ # In this case, we fake the date, because we only care about the
+ # DST flag.
tt = (2037,) + tt[1:]
stamp = time.mktime(tt)
tt = time.localtime(stamp)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---