While working on the web-proxy component of $dayjob’s software, I ran into a silly glitch with Date::Parse’s str2time() function. str2time converts string formatted timestamps (Thu, 13 Oct 94 10:13:13 -0700 for example) into epoch seconds (the number of seconds since a certain point in time in 1970) – very useful when working with the Last-Modified header that web servers offer up.
To fix an FTP caching bug, I needed to add a Last-Modified header to the cached file, and did this with a str2time() call, thus keeping the epoch time in the file. Perfectly logical. However, when the proxy came around to reading the header out of the file to see if the timestamp in the header was too old (ie, go fetch the file again), it applied str2time() to the value of the header. Now, I’d have assumed that if you feed epoch seconds to a string to epoch seconds converter, it’d realise that the format was already in epoch seconds and return the input value (there are flaws in this approach mind you). I assumed wrong 🙂 str2time(some_epoch_value) returns blank!
Live and learn.