Replace non-portable calls to time functions (localtime_r and gmtime_r) with portable versions; remove pthread mutex protection as non-portable between Windows and Linux.