1515# BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE,
1616# SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
1717#
18- # $Id: date.py,v 1.80 2005-02-25 17:15:47 a1s Exp $
18+ # $Id: date.py,v 1.81 2005-03-03 04:49:16 richard Exp $
1919
2020"""Date, time and time interval handling.
2121"""
@@ -135,6 +135,7 @@ def __init__(self, spec='.', offset=0, add_granularity=0, translator=i18n):
135135 elif have_datetime and isinstance (spec , datetime .datetime ):
136136 # Python 2.3+ datetime object
137137 y ,m ,d ,H ,M ,S ,x ,x ,x = spec .timetuple ()
138+ if y < 1970 : raise ValueError , 'year must be > 1970'
138139 S += spec .microsecond / 1000000.
139140 spec = (y ,m ,d ,H ,M ,S ,x ,x ,x )
140141 elif hasattr (spec , 'tuple' ):
@@ -143,6 +144,7 @@ def __init__(self, spec='.', offset=0, add_granularity=0, translator=i18n):
143144 spec = spec .get_tuple ()
144145 try :
145146 y ,m ,d ,H ,M ,S ,x ,x ,x = spec
147+ if y < 1970 : raise ValueError , 'year must be > 1970'
146148 frac = S - int (S )
147149 ts = calendar .timegm ((y ,m ,d ,H + offset ,M ,S ,0 ,0 ,0 ))
148150 self .year , self .month , self .day , self .hour , self .minute , \
@@ -195,6 +197,7 @@ def set(self, spec, offset=0, date_re=re.compile(r'''
195197 if info ['y' ] is not None or info ['a' ] is not None :
196198 if info ['y' ] is not None :
197199 y = int (info ['y' ])
200+ if y < 1970 : raise ValueError , 'year must be > 1970'
198201 m ,d = (1 ,1 )
199202 if info ['m' ] is not None :
200203 m = int (info ['m' ])
0 commit comments