def s3datetime_to_timestamp(datetime):
 try:
  stripped = time.strptime(datetime[:(-4)], '%a, %d %b %Y %H:%M:%S')
  assert (datetime[(-4):] == ' GMT'), ('Time [%s] is not in GMT.' % datetime)
 except ValueError:
  stripped = time.strptime(datetime[:(-5)], '%Y-%m-%dT%H:%M:%S')
  assert (datetime[(-5):] == '.000Z'), ('Time [%s] is not in GMT.' % datetime)
 return int(calendar.timegm(stripped))

def s3datetime_to_timestamp ( datetime ) : try : stripped = time . strptime ( datetime [ : ( - 4 ) ] , '%a, %d %b %Y %H:%M:%S' ) assert ( datetime [ ( - 4 ) : ] == ' GMT' ) , ( 'Time [%s] is not in GMT.' % datetime ) except ValueError : stripped = time . strptime ( datetime [ : ( - 5 ) ] , '%Y-%m-%dT%H:%M:%S' ) assert ( datetime [ ( - 5 ) : ] == '.000Z' ) , ( 'Time [%s] is not in GMT.' % datetime ) return int ( calendar . timegm ( stripped ) )
returns timestamp by datetime string from s3 api responses .