use localtime_r instead of localtime for the reason that thread safety