List:MySQL++« Previous MessageNext Message »
From:Андрей Покровский Date:February 8 2007 1:18pm
Subject:Known bug with localtime s in msvs7.1
View as plain text  
This will fix it (file datetime.cpp:194)

DateTime::DateTime(time_t t)
{
	struct tm tm;

#if defined(_MSC_VER) && !defined(_STLP_VERSION)	// we have MS compiler
	/*	Totaly, it's not a good idea to use _MSC_VER. It's just
		a compiler version, not runtime. To be more strictly
		one can use __CLR_VER. */
	#if (1400 <= _MSC_VER)	// MSVS 2005 or later
		localtime_s(&tm, &t);
	#else					// something else
		memcpy(&tm, localtime(&t), sizeof(tm));
	#endif

#elif defined(__MINGW32_VERSION)
	memcpy(&tm, localtime(&t), sizeof(tm));
#else
	localtime_r(&t, &tm);
#endif

	year = tm.tm_year + 1900;
	month = tm.tm_mon + 1;
	day = tm.tm_mday;
	hour = tm.tm_hour;
	minute = tm.tm_min;
	second = tm.tm_sec;
}
Thread
Known bug with localtime s in msvs7.1Андрей Покровский8 Feb
  • Re: Known bug with localtime_s in msvs7.1Warren Young20 Feb