def _validate_time(req, values):
 for time_field in ['created_at', 'updated_at', 'deleted_at']:
  if ((time_field in values) and values[time_field]):
   try:
    time = timeutils.parse_isotime(values[time_field])
    if (time.year < 1900):
     raise ValueError
    values[time_field] = time.strftime(timeutils.PERFECT_TIME_FORMAT)
   except ValueError:
    msg = (_('Invalid time format for %s.') % time_field)
    raise HTTPBadRequest(explanation=msg, request=req)

def _validate_time ( req , values ) : for time_field in [ 'created_at' , 'updated_at' , 'deleted_at' ] : if ( ( time_field in values ) and values [ time_field ] ) : try : time = timeutils . parse_isotime ( values [ time_field ] ) if ( time . year < 1900 ) : raise ValueError values [ time_field ] = time . strftime ( timeutils . PERFECT_TIME_FORMAT ) except ValueError : msg = ( _ ( 'Invalid time format for %s.' ) % time_field ) raise HTTPBadRequest ( explanation = msg , request = req )
validates time formats for updated_at .