Couldn't this just be 'return hours % 12'?