def time_to_epoch(t):
 if isinstance(t, int):
  return t
 elif (isinstance(t, tuple) or isinstance(t, time.struct_time)):
  return int(time.mktime(t))
 elif hasattr(t, 'timetuple'):
  return int(time.mktime(t.timetuple()))
 elif hasattr(t, 'strftime'):
  return int(t.strftime('%s'))
 elif (isinstance(t, str) or isinstance(t, unicode)):
  try:
   if t.startswith('+'):
    return (time.time() + int(t[1:]))
   return int(t)
  except ValueError:
   try:
    return time.strptime(t)
   except ValueError as ex:
    debug('Failed to parse date with strptime: %s', ex)
    pass
 raise S3.Exceptions.ParameterError(("Unable to convert %r to an epoch time. Pass an epoch time. Try `date -d 'now + 1 year' +%%s` (shell) or time.mktime (Python)." % t))

def time_to_epoch ( t ) : if isinstance ( t , int ) : return t elif ( isinstance ( t , tuple ) or isinstance ( t , time . struct_time ) ) : return int ( time . mktime ( t ) ) elif hasattr ( t , 'timetuple' ) : return int ( time . mktime ( t . timetuple ( ) ) ) elif hasattr ( t , 'strftime' ) : return int ( t . strftime ( '%s' ) ) elif ( isinstance ( t , str ) or isinstance ( t , unicode ) ) : try : if t . startswith ( '+' ) : return ( time . time ( ) + int ( t [ 1 : ] ) ) return int ( t ) except ValueError : try : return time . strptime ( t ) except ValueError as ex : debug ( 'Failed to parse date with strptime: %s' , ex ) pass raise S3 . Exceptions . ParameterError ( ( "Unable to convert %r to an epoch time. Pass an epoch time. Try `date -d 'now + 1 year' +%%s` (shell) or time.mktime (Python)." % t ) )
convert time specified in a variety of forms into unix epoch time .