Made timegm more portable

See man 3 timegm: http://linux.die.net/man/3/timegm