I tend to hate time with respect to programming. It always sucks when you have to dick around with timezones and daylight savings-this-and-that. Well, when a library uses functions that alter your environment, things tend to suck more.
Case in point, the PEAR Date class. It has two really cool functions called "after" and "before" that you can use to see if one date is after or before another date. Cool.
Well, the first problem was that the function alters your existing objects...so you don't have your original object after you use either function. Gay.
Ok, I fixed that. The next problem had to do with the way that the function compares the times. It converts both of them to UTC and then does the comparison. Ok, that all is fine and dandy...when you dont use the PHP "putenv" function to do that.
See, putenv modifies the environment that the script is running in. In this particular case, it sets an environment variable, TZ, to UTC...but it doesn't unset it. It assumes that the script execution will stop and putenv will restore the original value (which it will _if_ script execution stops).
In my case though script execution continues (this is a daemon). So it modifies the environment, changes my timezone from America/Chicago to UTC. And then all future time calculations are like 6 hours off. Way to go.
I fixed that too (I consider it a bug; dont touch my environment unless you untouch it).
With those 2 problems fixed, the Date class has mildly restored my confidence in it. I've made numerous other fixes and enhancements to the class and posted updated copies of the class on my work page in case you're interested. Apparently it's not maintained anymore? I dunno.