From: Vadim Zeitlin Date: Wed, 22 Jul 2009 17:56:35 +0000 (+0000) Subject: Use wxINT32_MAX instead of LONG_MAX as the upper bound in wxDateTime::IsInStdRange(). X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/57563c712bf8cc76650aecf33db066fcc20439d2 Use wxINT32_MAX instead of LONG_MAX as the upper bound in wxDateTime::IsInStdRange(). Under Debian Linux 64 bit time_t is 64 bit long but libc doesn't seem to handle values beyond 2^32 correctly, e.g. wrong results are returned from localtime() for them. And it would seem that platforms where sizeof(long) > sizeof(time_t) might exist too so it seems safer to only work with 32 bit time_t values until we can reliably detect platforms which support 64 bit ones. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61497 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/datetime.h b/include/wx/datetime.h index 351ced98ea..a431fd8e9f 100644 --- a/include/wx/datetime.h +++ b/include/wx/datetime.h @@ -1722,7 +1722,9 @@ protected: inline bool wxDateTime::IsInStdRange() const { - return m_time >= 0l && (m_time / TIME_T_FACTOR) < LONG_MAX; + // currently we don't know what is the real type of time_t so prefer to err + // on the safe side and limit it to 32 bit values which is safe everywhere + return m_time >= 0l && (m_time / TIME_T_FACTOR) < wxINT32_MAX; } /* static */