Check return value of gmtime() and add error codes