Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix localtime_r for VxWorks 6.9 and later #3274

Closed
wants to merge 11 commits into from
3 changes: 2 additions & 1 deletion Foundation/src/LocalDateTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ void LocalDateTime::determineTzd(bool adjust)
_tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0));
#else
std::tm broken;
#if defined(POCO_VXWORKS)
#if defined(POCO_VXWORKS) && (defined(_VXWORKS_COMPATIBILITY_MODE) || (defined(_WRS_VXWORKS_MAJOR) && ((_WRS_VXWORKS_MAJOR < 6) || ((_WRS_VXWORKS_MAJOR == 6) && (_WRS_VXWORKS_MINOR < 9)))))
if (localtime_r(&epochTime, &broken) != OK)
throw Poco::SystemException("cannot get local time");
#else
Expand All @@ -280,6 +280,7 @@ void LocalDateTime::determineTzd(bool adjust)
_tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0));
#endif
adjustForTzd();

}
else
{
Expand Down
4 changes: 4 additions & 0 deletions Foundation/src/Timezone_VX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ int Timezone::dst()
{
std::time_t now = std::time(NULL);
struct std::tm t;
#if defined(_VXWORKS_COMPATIBILITY_MODE) || (defined(_WRS_VXWORKS_MAJOR) && ((_WRS_VXWORKS_MAJOR < 6) || ((_WRS_VXWORKS_MAJOR == 6) && (_WRS_VXWORKS_MINOR < 9))))
if (localtime_r(&now, &t) != OK)
#else
if (!localtime_r(&now, &t))
#endif
throw Poco::SystemException("cannot get local time DST offset");
return t.tm_isdst == 1 ? 3600 : 0;
}
Expand Down