Use reentrant localtime if available
Merge pull request #5110 from t-nelson/prefer_localtime_r

Use reentrant localtime if available