Example #1
0
BOOL AddinHelper::TodayNotDo(const wchar_t* szValueName)
{
	DWORD dwLastUTC = 0;
	BOOL bCando = FALSE;
	ATL::CRegKey key;
	if (key.Open(HKEY_CURRENT_USER, REGEDITPATH) == ERROR_SUCCESS) {
		bCando = TRUE;
		if(key.QueryDWORDValue(szValueName, dwLastUTC) == ERROR_SUCCESS) {
			__time64_t tTime = (__time64_t)dwLastUTC;
			tm* pTm = _localtime64(&tTime);
			LONG nLastDay = pTm->tm_mday;
			LONG nLastMonth = pTm->tm_mon;
			LONG nLastYear = pTm->tm_year;

			__time64_t lCurTime;
			_time64( &lCurTime); 
			tm* pTmc = _localtime64(&lCurTime);

			LONG nCurDay = pTmc->tm_mday;
			LONG nCurMonth = pTmc->tm_mon;
			LONG nCurYear = pTmc->tm_year;
			TSDEBUG4CXX("TodayHasDo check time pTmc = "<<nCurYear<<nCurMonth<<nCurDay<<", pTm = "<<nLastYear<<nLastMonth<<nLastDay);
			if (nCurDay == nLastDay && nCurMonth == nLastMonth && nCurYear == nLastYear){
				bCando = FALSE;
			}
			else{
				bCando = TRUE;
			}
		}
		key.Close();
	}
	return bCando;
}
Example #2
0
long WINAPI DLLExport GetMonthDiff(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	if(p1==-1 || p2==-1)
		return -1;
	if(p1==p2)
		return 0;

	tm datetime;
	int mon1;
	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		datetime=*temptime;
		mon1=temptime->tm_mon;
	}
	else
	{
		datetime=rdPtr->datetime;
		mon1=datetime.tm_mon;
	}

	int year2, mon2;
	if(p2!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p2;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		year2=temptime->tm_year;
		mon2=temptime->tm_mon;
	}
	else
	{
		year2=rdPtr->datetime.tm_year;
		mon2=rdPtr->datetime.tm_mon;
	}

	datetime.tm_year=year2;
	datetime.tm_mon=mon2;
	__time64_t timestamp1a=_mktime64(&datetime);
	if(timestamp1a==-1) // shouldn't happen
		return -1;

	if((unsigned)p1>(unsigned)p2)
		if(timestamp1a>=(__time64_t)(unsigned)p2)
			return (mon1-mon2+12)%12;
		else
			return (mon1-mon2+11)%12;
	else
		if(timestamp1a<=(__time64_t)(unsigned)p2)
			return (mon1-mon2-12)%12;
		else
			return (mon1-mon2-11)%12;
}
Example #3
0
const gchar*
model_format_date(gint64 value)
{
    static gchar output[20];
    struct tm *tm;
    static gint day_now, month_now, year_now;
#ifdef G_OS_WIN32
    static __time64_t cached = 0;
    __time64_t ts_val, ts_now;

    ts_val = (__time64_t)value;
    ts_now = _time64(NULL);
    if(ts_now != cached)
    {
        tm = _localtime64(&ts_now);
        day_now = tm->tm_mday;
        month_now = tm->tm_mon;
        year_now = tm->tm_year;
        cached = ts_now;
    }
    tm = _localtime64(&ts_val);
#else
    static time_t cached = 0;
    time_t ts_val, ts_now;

    ts_val = (time_t)value;
    ts_now = time(NULL);
    if(ts_now != cached)
    {
        tm = localtime(&ts_now);
        day_now = tm->tm_mday;
        month_now = tm->tm_mon;
        year_now = tm->tm_year;
        cached = ts_now;
    }
    tm = localtime(&ts_val);
#endif

    if(conf_get_preferences_display_time_only() ||
       (tm->tm_mday == day_now &&
       tm->tm_mon == month_now &&
       tm->tm_year == year_now))
    {
        strftime(output, sizeof(output), "%H:%M:%S", tm);
    }
    else
    {
        strftime(output, sizeof(output), "%Y-%m-%d %H:%M:%S", tm);
    }

    return output;
}
struct tm* MightyTime::GetLocalTm(struct tm* ptm) const throw()
{
	if (ptm != NULL)
	{
		struct tm* ptmTemp = _localtime64(&m_time);
		if (ptmTemp == NULL)
			return NULL;    // indicates the m_time was not initialized!

		*ptm = *ptmTemp;
		return ptm;
	}
	else
		return _localtime64(&m_time);
}
Example #5
0
long WINAPI DLLExport GetHHMMSS(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	rdPtr->rHo.hoFlags |= HOF_STRING;
	if(p1==-1)
		return (long)"Error: Invalid TimeStamp";

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
			return (long)"Error: Invalid TimeStamp";
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
	}

	static char temp[7]="HHMMSS";
	temp[0]='0'+rdPtr->datetime.tm_hour/10;
	temp[1]='0'+rdPtr->datetime.tm_hour%10;
	temp[2]='0'+rdPtr->datetime.tm_min/10;
	temp[3]='0'+rdPtr->datetime.tm_min%10;
	temp[4]='0'+rdPtr->datetime.tm_sec/10;
	temp[5]='0'+rdPtr->datetime.tm_sec%10;
	return (long)temp;
}
Example #6
0
long WINAPI DLLExport GetYYYYMMDD(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	rdPtr->rHo.hoFlags |= HOF_STRING;
	if(p1==-1)
		return (long)"Error: Invalid TimeStamp";

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
			return (long)"Error: Invalid TimeStamp";
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
	}

	static char temp[9]="YYYYMMDD";
	temp[0]=(rdPtr->datetime.tm_year>=100)?'2':'1';//(rdPtr->datetime.tm_year+1900>=2000)
	temp[1]='0'+(rdPtr->datetime.tm_year/100+9)%10;
	temp[2]='0'+(rdPtr->datetime.tm_year/10)%10;
	temp[3]='0'+rdPtr->datetime.tm_year%10;
	temp[4]='0'+(rdPtr->datetime.tm_mon+1)/10;
	temp[5]='0'+(rdPtr->datetime.tm_mon+1)%10;
	temp[6]='0'+rdPtr->datetime.tm_mday/10;
	temp[7]='0'+rdPtr->datetime.tm_mday%10;
	return (long)temp;
}
Example #7
0
long WINAPI DLLExport AddSeconds(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	long p2=CNC_GetNextExpressionParameter(rdPtr, param1, TYPE_INT);
	if(p1==-1)
		return -1;

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		temptime->tm_sec+=p2;
		temptime->tm_isdst=-1;
		timestamp=_mktime64(temptime);
		if(timestamp>4294967294 || timestamp==-1)
			return -1;
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
		return (time_t)timestamp;
	}

	tm datetime;
	datetime=rdPtr->datetime;
	datetime.tm_sec+=p2;
//	datetime.tm_isdst=-1;
	__time64_t timestamp=_mktime64(&datetime);
	if(timestamp>4294967294 || timestamp==-1)
		return -1;
	rdPtr->datetime=datetime;
	rdPtr->timestamp=(time_t)timestamp;
	return (time_t)timestamp;
}
Example #8
0
File: mjd.c Project: q-bits/Antares
void time_to_tfdt64(__time64_t t, struct tf_datetime *dt)
{
    int y, m, d, k, mjd;
    struct tm *tm = _localtime64(&t);

    y = tm->tm_year;
    m = tm->tm_mon + 1;
    d = tm->tm_mday;

    if((m == 1) || (m == 2))
    {
        k = 1;
    }
    else
    {
        k = 0;
    }

    mjd = 14956 + d +
        ((int) ((y - k) * 365.25)) + ((int) ((m + 1 + k * 12) * 30.6001));
    put_u16(&dt->mjd, (__u16) mjd);
    dt->hour = (__u8) tm->tm_hour;
    dt->minute = (__u8) tm->tm_min;
    dt->second = (__u8) tm->tm_sec;
}
Example #9
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
char* formattedTime(const char* formatting, char* output)
{
  struct tm* t;
#ifdef _MSC_VER
#if _MSC_VER >= 1400
  struct tm time;
  errno_t tError;
#endif
#endif
  TimeType long_time;
  TimeFunc(&long_time);
  t = NULL;
#ifdef _MSC_VER
#if _MSC_VER < 1400
  t = _localtime64(&long_time);
#else
  t = &time;
  tError = _localtime64_s(&time, &long_time);
#endif
#else  // Non windows platforms
  t = localtime(&long_time);
#endif
  memset(output, 0, 128);
  snprintf(output, 128, formatting, t->tm_year + 1900, t->tm_mon + 1,
    t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec  );
  return output;
}
Example #10
0
void Logger::trace(int category, const UTF8String& sMsg)
{
    boost::mutex::scoped_lock Lock(log_Mutex);
    if (category & m_Flags) {
        struct tm* pTime;
#ifdef _WIN32
        __int64 now;
        _time64(&now);
        pTime = _localtime64(&now);
        DWORD tms = timeGetTime();
        unsigned millis = unsigned(tms % 1000);
#else
        struct timeval time;
        gettimeofday(&time, NULL);
        pTime = localtime(&time.tv_sec);
        unsigned millis = time.tv_usec/1000;
#endif
        char timeString[256];
        strftime(timeString, sizeof(timeString), "%y-%m-%d %H:%M:%S", pTime);
        cerr << "[" << timeString << "." << 
            setw(3) << setfill('0') << millis << setw(0) << "] ";
        cerr << categoryToString(category) << ": ";
        cerr << sMsg << endl;
        cerr.flush();
    }
}
Example #11
0
std::string CTimeUtil::GetCurrentTimeStr()
{
	struct tm* lt;
	// Get time as long integer
	__time64_t long_time = GetCurrentTime();
	// Convert to local time
	lt = _localtime64(&long_time);

	// Don't see how this can happen (according to docs _localtime64 only returns
	// NULL if long_time is before 1/1/1970...) but a user's stacktrace indicated
	// NULL newtime in the snprintf line...
	if (lt == NULL) {
		throw content_error("error: _localtime64 returned NULL");
	}

	const size_t str_maxSize = 512;
	char str[str_maxSize];
	SNPRINTF(str, str_maxSize, "%04i%02i%02i_%02i%02i%02i",
		lt->tm_year + 1900,
		lt->tm_mon + 1,
		lt->tm_mday,
		lt->tm_hour,
		lt->tm_min,
		lt->tm_sec);

	return str;
}
void CDemoRecorder::SetName(const std::string& mapname)
{
	struct tm *newtime;
	__time64_t long_time;
	_time64(&long_time);                /* Get time as long integer. */
	newtime = _localtime64(&long_time); /* Convert to local time. */

	// Don't see how this can happen (according to docs _localtime64 only returns
	// NULL if long_time is before 1/1/1970...) but a user's stacktrace indicated
	// NULL newtime in the snprintf line...
	if (!newtime)
		throw content_error("error: _localtime64 returned NULL");

	char buf[1000];
	SNPRINTF(buf, sizeof(buf), "%04i%02i%02i_%02i%02i%02i", newtime->tm_year+1900, newtime->tm_mon + 1, newtime->tm_mday,
        newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
	std::string name = std::string(buf) + "_" + mapname.substr(0, mapname.find_first_of("."));
	name += std::string("_") + SpringVersion::Get();
	// games without gameSetup should have different names
	if (!gameSetup) {
	    name = "local_" + name;
	}

	SNPRINTF(buf, sizeof(buf), "demos/%s.sdf", name.c_str());
	CFileHandler ifs(buf);
	if (ifs.FileExists()) {
		for (int a = 0; a < 9999; ++a) {
			SNPRINTF(buf, sizeof(buf), "demos/%s_(%i).sdf", name.c_str(), a);
			CFileHandler ifs(buf);
			if (!ifs.FileExists())
				break;
		}
	}
	wantedName = buf;
}
Example #13
0
static void GenerateFileName(wchar_t* buffer, size_t length)
{
    /* Generate the default filename from the current date */
    __time64_t t = _time64(NULL);
    struct tm* ltime = _localtime64(&t);
    wcsftime(buffer, length, L"screenshot_%Y-%m-%d_%H-%M-%S.png", ltime);
    free(ltime);
}
Example #14
0
std::string GetTime()
{
	struct tm *newtime;	__time64_t long_time;	char hour[3], min[3], sec[3];
	_time64( &long_time );                /* Get time as long integer. */
	newtime = _localtime64( &long_time ); /* Convert to local time. */
	//vytvorim string, do ktoreho si zapisem cas hod.min.sec
	return  (std::string)_itoa(newtime->tm_hour, hour, 10) + ":" +
			(std::string)_itoa(newtime->tm_min, min, 10) + ":" +
			(std::string)_itoa(newtime->tm_sec, sec, 10);
}
Example #15
0
struct tm* MMatchGetLocalTime()
{
	__time64_t long_time;

	_time64( &long_time );


	/* Obtain coordinated universal time: */
	return _localtime64( &long_time );
}
Example #16
0
	void log::write(const char *line)
	{
		char	temp[1024];	// Limit lines to 1024 characters
		__time64_t	_time;
		_time = time(&_time);
		struct tm *_tm;
		_tm = _localtime64(&_time);
		_snprintf(temp, 1024, "%02d:%02d=%s\n",  _tm->tm_hour, _tm->tm_min, line );
		raw(temp);
	}
Example #17
0
/*------------------------------------------------------------------------
 * ascdate  -  convert internal date/time to ascii
 * including hours:mins:secs.
 * buf is a pointer to a caller's array of at least 26 octets
 *------------------------------------------------------------------------
 */
char *ascdate(char *buf, size_t bufSize) {
	char *p_buf;
	struct tm *newtime;
	time_t ltime;
	_time64(&ltime);
	newtime = _localtime64(&ltime);
	asctime_s(buf, bufSize, newtime);
	p_buf = strchr(buf, '\n');
	*p_buf = 0;
	return buf;
}
Example #18
0
Bool
TimeUtil_UTCTimeToSystemTime(const __time64_t utcTime,   // IN
                             SYSTEMTIME *systemTime)     // OUT
{
   int atmYear;
   int atmMonth;

   struct tm *atm;

   /*
    * _localtime64 support years up through 3000.  At least it says
    * so.  I'm getting garbage only after reaching year 4408.
    */

   if (utcTime < 0 || utcTime > (60LL * 60 * 24 * 365 * (3000 - 1970))) {
      return FALSE;
   }

   atm = _localtime64(&utcTime);
   if (atm == NULL) {
      return FALSE;
   }

   atmYear = atm->tm_year + 1900;
   atmMonth = atm->tm_mon + 1;

   /*
    * Windows's SYSTEMTIME documentation says that these are limits...
    * Main reason for this test is to cut out negative values _localtime64
    * likes to return for some inputs.
    */

   if (atmYear < 1601 || atmYear > 30827 ||
       atmMonth < 1 || atmMonth > 12 ||
       atm->tm_wday < 0 || atm->tm_wday > 6 ||
       atm->tm_mday < 1 || atm->tm_mday > 31 ||
       atm->tm_hour < 0 || atm->tm_hour > 23 ||
       atm->tm_min < 0 || atm->tm_min > 59 ||
       /* Allow leap second, just in case... */
       atm->tm_sec < 0 || atm->tm_sec > 60) {
      return FALSE;
   }

   systemTime->wYear         = (WORD) atmYear;
   systemTime->wMonth        = (WORD) atmMonth;
   systemTime->wDayOfWeek    = (WORD) atm->tm_wday;
   systemTime->wDay          = (WORD) atm->tm_mday;
   systemTime->wHour         = (WORD) atm->tm_hour;
   systemTime->wMinute       = (WORD) atm->tm_min;
   systemTime->wSecond       = (WORD) atm->tm_sec;
   systemTime->wMilliseconds = 0;

   return TRUE;
}
Example #19
0
void CNet::CreateDemoFile()
{
	// We want this folder to exist
	if (!filesystem.CreateDirectory("demos"))
		return;

	if(gameSetup){
		struct tm *newtime;
		__time64_t long_time;
		_time64(&long_time);                /* Get time as long integer. */
		newtime = _localtime64(&long_time); /* Convert to local time. */

		char buf[500];
		sprintf(buf,"%02i%02i%02i",newtime->tm_year%100,newtime->tm_mon+1,newtime->tm_mday);
		string name=string(buf)+"-"+gameSetup->mapname.substr(0,gameSetup->mapname.find_first_of("."));
/*		for(int a=0;a<gameSetup->numPlayers;++a){
			name+="-"+gs->players[a]->playerName;
		}*/
		name+=string("-")+VERSION_STRING;

// This was a boost::filesystem workaround, I assume it can be trashed?
// 		for (int i = 0; i < name.length(); ++i)
// 			if (name[i] == ' ') name[i] = '_';

		sprintf(buf,"demos/%s.sdf",name.c_str());
		CFileHandler ifs(buf);
		if(ifs.FileExists()){
			for(int a=0;a<9999;++a){
				sprintf(buf,"demos/%s-%i.sdf",name.c_str(),a);
				CFileHandler ifs(buf);
				if(!ifs.FileExists())
					break;
			}
		}
		demoName = buf;
		recordDemo=new std::ofstream(filesystem.LocateFile(demoName, FileSystem::WRITE).c_str(), ios::out|ios::binary);

		// add a TDF section containing the game version to the startup script
		string scriptText = MakeDemoStartScript (gameSetup->gameSetupText, gameSetup->gameSetupTextLength);

		char c=1;
		recordDemo->write(&c,1);
		int len = scriptText.length();
		recordDemo->write((char*)&len, sizeof(int));
		recordDemo->write(scriptText.c_str(), scriptText.length());
	} else {
		demoName = "demos/test.sdf";
		recordDemo=new std::ofstream(filesystem.LocateFile(demoName, FileSystem::WRITE).c_str(), ios::out|ios::binary);
		char c=0;
		recordDemo->write(&c,1);
	}
}
Example #20
0
errno_t __cdecl _localtime64_s( struct tm * _tm, const __time64_t *time )
{
	errno_t retval = EINVAL;
	if( _tm && time && (time < 0) )
	{
		struct tm *tm2 = _localtime64( time );
		if( tm2 )
		{
			*_tm = *tm2;
			retval = 0;
		}
	}
	return retval;
}
Example #21
0
char const * print_time(time_t const & src_time, string64 & dest_time)
{
	tm* tmp_tm = _localtime64(&src_time);
	xr_sprintf(dest_time, sizeof(dest_time),
		"%02d.%02d.%d_%02d:%02d:%02d",
		tmp_tm->tm_mday, 
		tmp_tm->tm_mon+1, 
		tmp_tm->tm_year+1900, 
		tmp_tm->tm_hour, 
		tmp_tm->tm_min, 
		tmp_tm->tm_sec
	);
	return dest_time;
}
Example #22
0
/*--------------------------------------------------------------------------*/
double * getConvertedDateAsDoubleVector(double dDate, int *iErr)
{
    double *dVector = (double*) MALLOC(sizeof(double) * NB_ELEMNT_ARRAY_GETDATE);
    *iErr = 1;
    if (dVector)
    {
        struct tm *tstruct = NULL;
        double milliseconds = 0.;
#ifdef _MSC_VER
        __time64_t instantT = (__time64_t)dDate;
        tstruct = _localtime64(&instantT);
#else
        time_t instantT = (time_t)dDate;
        tstruct = localtime(&instantT);
#endif
        milliseconds = dDate - (double)instantT;
        if (milliseconds > 0)
        {
            if (milliseconds > 999)
            {
                milliseconds = (double)999;
            }
        }
        else
        {
            milliseconds = 0.;
        }

        if (tstruct)
        {
            dVector[YEAR_INDEX] =           (double)(1900 + tstruct->tm_year);
            dVector[MONTH_INDEX] =          (double)(1    + tstruct->tm_mon);
            dVector[WEEK_NUMBER_INDEX] =    (double)(week_number(tstruct));
            dVector[DAY_OF_YEAR_INDEX] =    (double)(1    + tstruct->tm_yday);
            dVector[WEEKDAY_INDEX] =        (double)(1    + tstruct->tm_wday);
            dVector[DAY_OF_MONTH_INDEX] =   (double)(tstruct->tm_mday);
            dVector[HOUR_OF_DAY_INDEX] =    (double)(tstruct->tm_hour);
            dVector[MINUTE_INDEX] =         (double)(tstruct->tm_min);
            dVector[SECOND_INDEX] =         (double)(tstruct->tm_sec);
            dVector[MILLISECOND_INDEX] =    (double)milliseconds;
            *iErr = 0;
        }
        else
        {
            *iErr = 2;
        }
    }
    return dVector;
}
Example #23
0
/*--------------------------------------------------------------------------*/
double *getCurrentDateAsDoubleVector(int *iErr)
{
    double *dVector = (double*) MALLOC(sizeof(double) * NB_ELEMNT_ARRAY_GETDATE);
    *iErr = 1;
    if (dVector)
    {
        struct tm *nowstruct = NULL;
        double milliseconds = 0.;
#ifdef _MSC_VER
        /* manages date  up through 23:59:59, December 31, 3000 */
        /* previous version was limited to  19:14:07 January 18, 2038, UTC. */
        __time64_t long_time;
        struct __timeb64 tstruct;
        _ftime64(&tstruct);
        long_time = tstruct.time;
        nowstruct = _localtime64(&long_time);
#else
        struct timeval timebuffer;
        gettimeofday(&timebuffer, NULL);
        nowstruct = localtime(&timebuffer);
#endif

#ifdef _MSC_VER
        milliseconds = (double)(tstruct.millitm);
#else
        milliseconds = (double)(timebuffer.tv_usec / 1000);  /* micro to ms */
#endif
        if (milliseconds < 0)
        {
            milliseconds = 0.;
        }

        if (nowstruct)
        {
            dVector[YEAR_INDEX] =           (double)(1900 + nowstruct->tm_year);
            dVector[MONTH_INDEX] =          (double)(1    + nowstruct->tm_mon);
            dVector[WEEK_NUMBER_INDEX] =    (double)(week_number(nowstruct));
            dVector[DAY_OF_YEAR_INDEX] =    (double)(1    + nowstruct->tm_yday);
            dVector[WEEKDAY_INDEX] =        (double)(1    + nowstruct->tm_wday);
            dVector[DAY_OF_MONTH_INDEX] =   (double)(nowstruct->tm_mday);
            dVector[HOUR_OF_DAY_INDEX] =    (double)(nowstruct->tm_hour);
            dVector[MINUTE_INDEX] =         (double)(nowstruct->tm_min);
            dVector[SECOND_INDEX] =         (double)(nowstruct->tm_sec);
            dVector[MILLISECOND_INDEX] =    (double)milliseconds;
            *iErr = 0;
        }
    }
    return dVector;
}
Example #24
0
LPCSTR inline file_name()
{
	static string_path			file = " ";
	if(file[0]==' '){
		_mkdir					(output_folder);

		__time64_t				long_time;
		_time64					(&long_time);
		tm						new_time;
		new_time				= *_localtime64(&long_time);
		string256				file_name;
		strftime				(file_name,sizeof(file_name),"%Y.%m.%d.%H.%M.%S",&new_time);
		strconcat				(sizeof(file),file,output_folder,file_name,output_extension);
	}
	return file;
}
Example #25
0
static int datetime(lua_State *L){
	struct tm *newtime;
	__int64 ltime;

	_time64(&ltime);

	// Obtain coordinated universal time:
	newtime = _localtime64(&ltime); // C4996

	lua_pushinteger(L, newtime->tm_year + 1900);
	lua_pushinteger(L, newtime->tm_mon);
	lua_pushinteger(L, newtime->tm_mday);
	lua_pushinteger(L, newtime->tm_hour);
	lua_pushinteger(L, newtime->tm_min);
	lua_pushinteger(L, newtime->tm_sec);
	return 6;
}
Example #26
0
	const wchar_t *log::get_currentFile()
	{
		__time64_t	_time;
		_time = time(&_time);
		struct tm *_tm;
		_tm = _localtime64(&_time);
		size_t i = wcslen(wcscpy(m_logFile,get_appdataDir()));
		if( *(m_logFile + i - 1) != '\\' )
		{	// Append a backslash if it is missing.
			m_logFile[i++] = '\\';
			m_logFile[i] = 0;
		}
		wcscat(m_logFile,L"lologs");
		_wmkdir(m_logFile);
		_snwprintf( m_logFile + wcslen(m_logFile), MAX_PATH - i, L"\\%s-%04d%02d%02d.log", get_moduleName(), _tm->tm_year+1970, _tm->tm_mon + 1, _tm->tm_mday );

		return m_logFile;
	}
Example #27
0
long WINAPI DLLExport GetDayofWeek(LPRDATA rdPtr, long param1)
{
	long p1=CNC_GetFirstExpressionParameter(rdPtr, param1, TYPE_INT);
	if(p1==-1)
		return -1;

	if(p1!=rdPtr->timestamp)
	{
		__time64_t timestamp=(unsigned)p1;
		tm *temptime=_localtime64(&timestamp);
		if(temptime==0)
            return -1;
		rdPtr->datetime=*temptime;
		rdPtr->timestamp=p1;
		return temptime->tm_wday;
	}
	return rdPtr->datetime.tm_wday;
}
Example #28
0
static char const * current_time(string64 & dest_time)
{
	time_t		tmp_curr_time;
	
	dest_time[0]	= 0;
	_time64			(&tmp_curr_time);
	tm* tmp_tm		= _localtime64(&tmp_curr_time);

	sprintf_s(dest_time, sizeof(dest_time),
		"%02d.%02d.%d_%02d:%02d:%02d",
		tmp_tm->tm_mday, 
		tmp_tm->tm_mon+1, 
		tmp_tm->tm_year+1900, 
		tmp_tm->tm_hour, 
		tmp_tm->tm_min, 
		tmp_tm->tm_sec
	);
	return dest_time;
}
Example #29
0
		void log(const std::wstring category, const wchar_t* file, const int line, const wchar_t* message) {
			TCHAR buffer[65];
			__time64_t ltime;
			_time64( &ltime );
			struct tm *today = _localtime64( &ltime );
			if (today) {
				size_t len = wcsftime(buffer, 63, datemask_.c_str(), today);
				if ((len < 1)||(len > 64))
					wcsncpy(buffer, 64, _T("???"));
				else
					buffer[len] = 0;
			} else {
				wcsncpy(buffer, 64, _T("<unknown time>"));
			}
			std::wstring logline = std::wstring(buffer) + _T(": ") + category + _T(":") + std::wstring(file) + _T(":") + strEx::itos(line) +_T(": ") + message + _T("\r\n");
			if (!writeEntry(logline)) {
				std::wcerr << _T("Failed to write: ") << logline;
			}
		}
Example #30
0
	virtual void GetHistoryForParticipant_CB(GetHistoryForParticipant_PostgreSQLImpl *callResult, bool wasCancelled, void *context)
	{
		if (wasCancelled)
			printf("GetHistoryForParticipant call cancelled:\n");
		else if (callResult->dbQuerySuccess==false)
		{
			printf("GetHistoryForParticipant call DB failure:\n");
			printf("%s", callResult->rankingServer->GetLastError());
		}
		else
		{
			printf("GetHistoryForParticipant result:\n");
			printf("[in] participantDbId.primaryKey=%i\n", callResult->participantDbId.primaryKey);
			printf("[in] participantDbId.secondaryKey=%i\n", callResult->participantDbId.secondaryKey);
			printf("[in] gameDbId.primaryKey=%i\n", callResult->gameDbId.primaryKey);
			printf("[in] gameDbId.secondaryKey=%i\n", callResult->gameDbId.secondaryKey);
			printf("[out] %i matches found for this participant.\n", callResult->matchHistoryList.Size());
			unsigned i;
			for (i=0; i < callResult->matchHistoryList.Size(); i++)
			{
				printf("[out] %i. participantBDbId.primaryKey (opponent) =%i\n", i+1, callResult->matchHistoryList[i]->participantBDbId.primaryKey);
				printf("[out] %i. participantBDbId.secondaryKey (opponent) =%i\n", i+1, callResult->matchHistoryList[i]->participantBDbId.secondaryKey);
				printf("[out] %i. participantAScore (us) =%f\n", i+1, callResult->matchHistoryList[i]->participantAScore);
				printf("[out] %i. participantBScore (opponent) =%f\n", i+1, callResult->matchHistoryList[i]->participantBScore);
				printf("[out] %i. participantAOldRating (us) =%f\n", i+1, callResult->matchHistoryList[i]->participantAOldRating);
				printf("[out] %i. participantANewRating (us) =%f\n", i+1, callResult->matchHistoryList[i]->participantANewRating);
				printf("[out] %i. participantBOldRating (opponent) =%f\n", i+1, callResult->matchHistoryList[i]->participantBOldRating);
				printf("[out] %i. participantBNewRating (opponent) =%f\n", i+1, callResult->matchHistoryList[i]->participantBNewRating);
				printf("[out] %i. Match Notes=%s\n", i+1, callResult->matchHistoryList[i]->matchNotes.C_String());
				printf("[out] %i. matchBinaryDataLength=%i\n", i+1, callResult->matchHistoryList[i]->matchBinaryDataLength);

				// Copied from the docs
				struct tm *newtime;
				newtime = _localtime64(& callResult->matchHistoryList[i]->matchTime);
				char buff[30];
				asctime_s( buff, sizeof(buff), newtime );
				printf("[out] %i. matchTime (converted) =\n%s\n", i+1, buff );
			}
		}

		printf("\n");
	}