localtime() may return NULL, as documented on MSDN and Linux man pages,

and it has been observed to do that on at least one FB user’s Windows system, because of a negative time_t value from time().