FYI: asctime(gmtime(&mytime)) = crash!
After a debugging session, I thought I would post this.
If asctime is called with NULL it will crash. Unfortunately, both localtime and gmtime can return NULL if the argument is an invalid value. Therefore both of:
can crash a program. Most of the samples mentioned with asctime do not check the return value of gmtime or localtime and are therefore unsafe.
ctime on my compiler does not crash, however, according to the docs, ctime is equivalent to asctime(localtime(&timer)); so it may also crash with some compilers.
Hopefully this can help someone.