Electronic and optical properties of hexathiapentacene in the gas and crystal phases