A local equation of state for a fluid in the presence of a wall and its application to rewetting