Fix undefined behavior in ctime()