@ -140,12 +140,22 @@ class DateStrptime(DateTemplate):
conv = self . convertLocale ( dateMatch . group ( ) )
conv = self . convertLocale ( dateMatch . group ( ) )
try :
try :
date = list ( time . strptime ( conv , self . getPattern ( ) ) )
date = list ( time . strptime ( conv , self . getPattern ( ) ) )
except ValueError , e :
except ( ValueError , re . error ) , e :
# Try to add the current year to the pattern. Should fix
# Try to add the current year to the pattern. Should fix
# the "Feb 29" issue.
# the "Feb 29" issue.
opattern = self . getPattern ( )
# makes sense only if %Y is not in already:
if not ' % Y ' in opattern :
pattern = " %s %% Y " % opattern
conv + = " %s " % MyTime . gmtime ( ) [ 0 ]
conv + = " %s " % MyTime . gmtime ( ) [ 0 ]
pattern = " %s %% Y " % self . getPattern ( )
date = list ( time . strptime ( conv , pattern ) )
date = list ( time . strptime ( conv , pattern ) )
else :
# we are helpless here
raise ValueError (
" Given pattern %r does not match. Original "
" exception was %r and Feb 29 workaround could not "
" be tested due to already present year mark in the "
" pattern " % ( opattern , e ) )
if date [ 0 ] < 2000 :
if date [ 0 ] < 2000 :
# There is probably no year field in the logs
# There is probably no year field in the logs
date [ 0 ] = MyTime . gmtime ( ) [ 0 ]
date [ 0 ] = MyTime . gmtime ( ) [ 0 ]