Implement timegm. Taken from rtmpd.