On 10/11/21 4:12 AM, Alejandro Colomar wrote:
time_t portable_timegm(struct tm *tm) { tm->tm_isdst = 0; /* * If another thread modifies the timezone during the * execution of the line below, it will produce undefined * behavior. */ return mktime(tm) - timezone; }
This doesn't work for multiple reasons: it's not thread-safe, mktime might set timezone even in a single-threaded app, and the subtraction might overflow.