use mutex to protect localtime and gmtime function.