Source

trac-1942 / robust_old_dates.diff

Full commit
# HG changeset patch
# Parent 60d90d3bd1b779ab631592b4610143c68667ce0b
More robust handling of really old dates.
`time.mktime()` apparently can raise `ValueError` or `OverflowError` depending no platform / date.
For me dates before 1900 raise ValueError, dates between 1900 and 1970 raise OverflowError.

Related but unsolved: `datetime.strftime()` dislikes years before 1900 too
See also http://bugs.python.org/issue1777412

diff -r 60d90d3bd1b7 trac/util/datefmt.py
--- a/trac/util/datefmt.py	Fri Mar 02 09:41:39 2012 +0100
+++ b/trac/util/datefmt.py	Fri Mar 02 14:01:16 2012 +0100
@@ -802,6 +802,8 @@
             return tt.tm_isdst > 0
         except OverflowError:
             return False
+        except ValueError:
+            return False
 
     def localize(self, dt, is_dst=False):
         if dt.tzinfo is not None: