Generalize check for localtime_r

Use the _POSIX_THREAD_SAFE_FUNCTIONS define to decide
whether localtime_r is available, instead of guessing
by Mingw-w64 version.

This copies the logic of qdatetime.cpp in qtbase, and
should fix compilations with older Mingw-w64 versions.
It replaces ce3e8f93c.

Task-number: QTBUG-34038
Change-Id: Iee8a9aa61d2af3e069e6365c40f81007c479d147
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>