예제 #1
0
void LocalDateTime::determineTzd(bool adjust)
{
	if (adjust)
	{
		std::time_t epochTime = _dateTime.timestamp().epochTime();
#if defined(_WIN32) || defined(POCO_NO_POSIX_TSF)
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
		std::tm* broken = wceex_localtime(&epochTime);
#else
		std::tm* broken = std::localtime(&epochTime);
#endif
		if (!broken) throw Poco::SystemException("cannot get local time");
		_tzd = (Timezone::utcOffset() + ((broken->tm_isdst == 1) ? 3600 : 0));
#else
		std::tm broken;
#if defined(POCO_VXWORKS)
		if (localtime_r(&epochTime, &broken) != OK)
			throw Poco::SystemException("cannot get local time");
#else
		if (!localtime_r(&epochTime, &broken))
			throw Poco::SystemException("cannot get local time");
#endif
		_tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0));
#endif
		adjustForTzd();
	}
	else
	{
		int dst;
		dstOffset(dst);
		_tzd = (Timezone::utcOffset() + dst);
	}
}
예제 #2
0
bool Timezone::isDst(const Timestamp& timestamp)
{
	std::time_t time = timestamp.epochTime();
#if _WIN32_WCE >= 0x800
	struct std::tm* tms = localtime(&time);
#else
	struct std::tm* tms = wceex_localtime(&time);
#endif
	if (!tms) throw SystemException("cannot get local time DST flag");
	return tms->tm_isdst > 0;
}
예제 #3
0
파일: util.c 프로젝트: k2b3d/client_new
void GetCurrentDate(char *szDate)
{
	time_t t ;
	struct tm TP ;
	struct tm *p;

#ifdef _WIN32_WCE
	t = wceex_time(&t) ;
	memcpy(&TP, wceex_localtime(&t), sizeof(TP));
#else
	t = time(&t);
	memcpy(&TP, localtime(&t), sizeof(TP));	
#endif

	p = &TP;
	sprintf(szDate, "%04d%02d%02d", p->tm_year+1900, p->tm_mon+1, p->tm_mday);
}
예제 #4
0
/*******************************************************************************
* wceex_ctime - Convert a time value to a date and time string
*
* Description:
*
*   The ctime function is similar to asctime, except that you specify
*   the calendar time argument as a time_t simple time value rather
*   than in broken-down local time format.
*   It shall be equivalent to: asctime(localtime(clock))
*
*   The ctime() is not required to be thread-safe.
*
*   Windows CE specific:
*       ctime does not set the variable tzname.
*
* Reference:
*
*   IEEE Std 1003.1-2001
*   The GNU C Library Manual
* 
*******************************************************************************/
char * wceex_ctime(const time_t *timer)
{
   return wceex_asctime(wceex_localtime(timer));
}