Core/Misc: Remove unsafe not thread-safe localtime() calls

Replace not thread-safe localtime() calls with thread-safe localtime_r().