For some reason this code:
localtime()+(param("saleend") * 24 * 60 * 60)
is putting the output of 604800 which is the param("saleend" * 24 * 60 * 60) (saleend is equal to 7).
Why would localtime() not have a value? Is it NOT a built in Perl function?
localtime() returns either an array of numbers representing seconds, minutes, hours, etc., or a string that represents date/time in a human readable form.
What you need there is time(), not localtime().