[Reviewer: Andy] Use gmtime_r to avoid threading conflicts

Andy, can you review my fix to remove a race condition if gmtime and localtime were called in separate threads?