Talk:c/chrono/mktime

Example
What part of the original example was the undefined behavior that prompted the redo last February? Was it the use of the static data or was the error checking improperly implemented? Newatthis (talk) 07:47, 24 May 2015 (PDT)
 * I believe I was thinking of the C89 and POSIX rule that calling any one of asctime, ctime, gmtime, localtime invalidated both static objects (the struct tm and the char array). This changed in C99 (7.23.3p1) to only let them clobber objects of the type they return, so looks like it's not UB after all. --Cubbi (talk) 07:47, 1 June 2015 (PDT)


 * In that case, what portions of the example as it existed on 17 June 2014 (before your edit) might be returned to this page? I am thinking particularly about the error check that follows the call to mktime. Also, might "struct tm *tmptr" be returned?Newatthis (talk) 05:51, 4 June 2015 (PDT)


 * holding a pointer to libc's tm doesn't strike me as commendable practice even when not using _r/_s versions of the tm functions. I wouldn't write than in production code and wouldn't pass it in code review, would you? Error checking was rather noisy; unnecessary cast to time_t (and more redundant parentheses around its result) and custom invented formatting for the message. Think about what is used in practice. I would assert or perror as the lowest common denominator, or just skip it as I did, since the input is guaranteed (unless you set the system clock to 1970). --Cubbi (talk) 06:35, 4 June 2015 (PDT)


 * OK, thanks. I continue to learn what is typical usage and what will pass a code review. When you edit one of my examples, I do try to use your changes as a role model in future contributions. Newatthis (talk) 04:55, 6 June 2015 (PDT)

weird: parameter 'time' in ddecl become a link to function 'time'
In the :

You can click that parameter 'time' as a link and jump to page c/chrono/time.

I think it would be weird. Is there any solution to this?


 * Fixed by renaming the parameter to . The identifier  is reserved (i.e. in the "GeSHi" list) and associated with this page.) --Space Mission (talk) 09:24, 26 August 2022 (PDT)