示例#1
3
/**
* @see clock.h
* @private
* Mock a clock on the PC 
* @param clockParam the clock
*/
ClockData* _readPcClock(Clock* clockParam) {
    time_t rawtime;
    struct tm timeinfo;
    time(&rawtime);
    localtime_s(&timeinfo, &rawtime);

    ClockData* data = &(clockParam->clockData);
    data->year = timeinfo.tm_year - 100; // we store the date after 2000 (100 = 2000 - 1900)
    data->month = timeinfo.tm_mon;
    data->day = timeinfo.tm_mday;
    data->dayofweek = timeinfo.tm_wday;
    data->hour = timeinfo.tm_hour;
    data->minute = timeinfo.tm_min;
    data->second = timeinfo.tm_sec;

    return &(clockParam->clockData);
}
示例#2
0
文件: log.cpp 项目: 12019/svn.gov.pt
////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// PRIVATE FUNCTIONS ////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
void getLocalTime(std::wstring &timestamp)
{
	time_t rawtime;
	struct tm timeinfo;
	wchar_t buffer [20];

	time ( &rawtime );
#ifdef WIN32
	localtime_s( &timeinfo, &rawtime );
#else
	timeinfo = *(localtime(&rawtime));
#endif

	wcsftime (buffer,20,L"%Y-%m-%d %H:%M:%S",&timeinfo);

	timestamp.assign(buffer);
}
示例#3
0
void getLocalTime(const time_t* localTime, struct tm* localTM)
{
#if PLATFORM(QT)
#if USE(MULTIPLE_THREADS)
#error Mulitple threads are currently not supported in the Qt/mingw build
#endif
    *localTM = *localtime(localTime);
#elif PLATFORM(WIN_OS)
    #if COMPILER(MSVC7)
    *localTM = *localtime(localTime);
    #else
    localtime_s(localTM, localTime);
    #endif
#else
    localtime_r(localTime, localTM);
#endif
}
void SessionServer::TeardownFileLogger()
{
    time_t curTime = time(NULL);
    tm curTM;
    localtime_s(&curTM, &curTime);
    
	m_logger->ClearWriter();

    std::string curTimeString = GetCurrentDateTimeString(curTM);

    LogInfo(" ** Logging Session Ended at %s", curTimeString.c_str());
    if (m_logWriter)
    {
        delete m_logWriter;
        m_logWriter = NULL;
    }
}
示例#5
0
void SimpleDate::now()
{
	std::chrono::system_clock::time_point p = std::chrono::system_clock::now();
	time_t t = std::chrono::system_clock::to_time_t(p);
#ifdef _WIN32
	tm timeinfo;
	localtime_s(&timeinfo, &t);
	year = 1900 + timeinfo.tm_year;
	month = 1 + timeinfo.tm_mon;
	day = timeinfo.tm_mday;
#else
	tm *timeinfo = localtime(&t);
	year = std::to_string(1900 + timeinfo->tm_year);
	month = std::to_string(1 + timeinfo->tm_mon);
	day = std::to_string(timeinfo->tm_mday);
#endif
}
示例#6
0
void GetDefaultFiles(const char *logBaseName, string &capture_filename, string &logging_filename,
                     string &target)
{
  wchar_t temp_filename[MAX_PATH];

  GetTempPathW(MAX_PATH, temp_filename);

  wchar_t curFile[512];
  GetModuleFileNameW(NULL, curFile, 512);

  wchar_t fn[MAX_PATH];
  wcscpy_s(fn, MAX_PATH, curFile);

  wchar_t *mod = wcsrchr(fn, L'.');
  if(mod)
    *mod = 0;
  mod = wcsrchr(fn, L'/');
  if(!mod)
    mod = fn;
  mod = wcsrchr(mod, L'\\');

  mod++;    // now points to base filename without extension

  target = StringFormat::Wide2UTF8(wstring(mod));

  time_t t = time(NULL);
  tm now;
  localtime_s(&now, &t);

  wchar_t *filename_start = temp_filename + wcslen(temp_filename);

  wsprintf(filename_start, L"%ls_%04d.%02d.%02d_%02d.%02d.rdc", mod, 1900 + now.tm_year,
           now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min);

  capture_filename = StringFormat::Wide2UTF8(wstring(temp_filename));

  *filename_start = 0;

  wstring wbase = StringFormat::UTF82Wide(string(logBaseName));

  wsprintf(filename_start, L"%ls_%04d.%02d.%02d_%02d.%02d.%02d.log", wbase.c_str(),
           1900 + now.tm_year, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);

  logging_filename = StringFormat::Wide2UTF8(wstring(temp_filename));
}
示例#7
0
int main(void)
{
  const char *day[7] = {
                   "Sunday"  , "Monday", "Tuesday", "Wednesday",
                   "Thursday", "Friday", "Saturday"
                       };
  const char *month[12] = {
                     "January",   "February", "March",    "April",
                     "May",       "June",     "July",     "August",
                     "September", "October",  "November", "December"
                          };
  const char *suffix[] = { "st", "nd", "rd", "th" };
  enum sufindex { st, nd, rd, th } sufsel = th;       // Suffix selector

  struct tm ourT;                                     // The time structure
  time_t tVal = time(NULL);                           // Calendar time

  if(!localtime_s(&tVal, &ourT))                      // Populate time structure
  {
    fprintf_s(stderr, "Failed to populate tm struct.\n");
    return -1;
  }

  switch(ourT.tm_mday)
  {
    case 1: case 21: case 31:
      sufsel= st;
      break;
    case 2: case 22:
      sufsel= nd;
      break;
    case 3: case 23:
      sufsel= rd;
      break;
    default:
      sufsel= th;
      break;
  }

  printf_s("Today is %s the %d%s %s %d. ", day[ourT.tm_wday],
    ourT.tm_mday, suffix[sufsel], month[ourT.tm_mon], 1900 + ourT.tm_year);
  printf_s("The time is %d : %d : %d.\n",
    ourT.tm_hour, ourT.tm_min, ourT.tm_sec );
  return 0;
}
示例#8
0
int getCurrentDateTimeStringWithSeparator(char *dateString, char dateSeparator, char *timeString, char timeSeparator)
{
    static const char *wday[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
    time_t t;
    struct tm tmobj;

    time(&t);
    localtime_s(&tmobj, &t);

    if (dateString)
    {
        if (dateSeparator == '\0')
        {
            sprintf_s(dateString, TIMESTRING_BUFFER_SIZE, "%04d%02d%02d",
                (1900 + tmobj.tm_year),
                (1 + tmobj.tm_mon),
                tmobj.tm_mday);
        }
        else {
            sprintf_s(dateString, TIMESTRING_BUFFER_SIZE, "%04d%c%02d%c%02d",
                (1900 + tmobj.tm_year), dateSeparator,
                (1 + tmobj.tm_mon), dateSeparator,
                tmobj.tm_mday);
        }
    }

    if (timeString)
    {
        if (timeSeparator == '\0')
        {
            sprintf_s(timeString, TIMESTRING_BUFFER_SIZE, "%02d%02d%02d",
                tmobj.tm_hour,
                tmobj.tm_min,
                tmobj.tm_sec);
        }
        else {
            sprintf_s(timeString, TIMESTRING_BUFFER_SIZE, "%02d%c%02d%c%02d",
                tmobj.tm_hour, timeSeparator,
                tmobj.tm_min, timeSeparator,
                tmobj.tm_sec);
        }
    }

    return 1;
}
示例#9
0
void RichEditEventLogger::AddToLog(LogLevel level, uint8_t * data, int32_t length, const TCHAR * msg, ...)
{
	if (level < m_LogLevel)
	{
		return;
	}

	TCHAR * pLogMsg = logMsgBuffer;
	time_t rawtime;
	struct tm timeinfo;

	time(&rawtime);
	localtime_s(&timeinfo, &rawtime);

	_tcsftime(pLogMsg, MAX_LOG_MSG_LENGTH, _T("%d-%m-%Y %I:%M:%S: "), &timeinfo);
	pLogMsg += _tcslen(logMsgBuffer);

	va_list argptr;
	va_start(argptr, msg);
	_vstprintf_s(pLogMsg, MAX_LOG_MSG_LENGTH - _tcslen(logMsgBuffer), msg, argptr);
	va_end(argptr);

	int32_t logMsgLength = sizeof(logMsgBuffer) / sizeof(TCHAR);
	int32_t currentLength = _tcslen(logMsgBuffer);

	TCHAR hexStr[16];
	for (int32_t i = 0; i < length; i++)
	{
		if ((i % 16) == 0)
		{
			_tcscat_s(logMsgBuffer, logMsgLength - currentLength, _T("\n"));
			currentLength = _tcslen(logMsgBuffer);
			pLogMsg = logMsgBuffer + currentLength;
		}
		_stprintf_s(hexStr, sizeof(hexStr) / sizeof(TCHAR), _T(" %02X"), data[i]);
		_tcscat_s(pLogMsg, logMsgLength - currentLength, hexStr);
		currentLength += _tcslen(hexStr);
		pLogMsg = logMsgBuffer + currentLength;
	}
	_tcscat_s(pLogMsg, logMsgLength - currentLength, _T("\n"));

	m_Logger->SetSel(-1, -1);
	m_Logger->ReplaceSel(logMsgBuffer);
	m_Logger->PostMessage(WM_VSCROLL, SB_BOTTOM, NULL);
}
示例#10
0
///////////////////////////////////////////////////////////////////////////////
// Debugger - Constructor for debugger class
Debug::Debugger::Debugger(Bool bLogging)
{
    m_bLogging = bLogging;

#if defined ( WIN32 ) || defined ( WIN64 )
    // Create critical section
    m_CsFileWrite = new CRITICAL_SECTION;
    InitializeCriticalSection( m_CsFileWrite );
#else
    ASSERT( False );  // Only Windows critical sections are supported
#endif

    if(m_bLogging)
    {
	    // Copy the s_LogFiles into the instance
	    memcpy( m_LogFiles, s_LogFiles, sizeof( s_LogFiles ) );

	    // Create a directory with the current timestamp
        // ( Format: Month_Day_HourMinute )
	    time_t Time;
	    time( &Time );

	    tm Date;
	    localtime_s( &Date, &Time );

	    char FolderName[ MAX_STRING_LENGTH ];
	    sprintf_s( FolderName, MAX_STRING_LENGTH, "..\\Logs\\%.2d%.2d%.2d%.2d\\", (Date.tm_mon + 1), Date.tm_mday, Date.tm_hour, Date.tm_min );

	    int Result = _mkdir( FolderName );
        
        ASSERT( Result == 0 );
        if( Result == 0 )
        {
	        // Open all the log files
	        for( u8 Index = 0; Index < LogType::e_LogTypeCount; Index++ )
	        {
		        char FileName[ MAX_STRING_LENGTH ];
		        strncpy_s( FileName, MAX_STRING_LENGTH, FolderName, MAX_STRING_LENGTH - strlen( m_LogFiles[ Index ].FileName ) );
		        strcat_s( FileName, MAX_STRING_LENGTH, m_LogFiles[ Index ].FileName );

		        fopen_s( &m_LogFiles[ Index ].FileHandle, FileName, "w" );
	        }
        }
    }
}
示例#11
0
void side::makeLine(const _finddata_t &finfo, string &str) const
{
	str.clear();
	str += char(179);

	/*name*/
	if (strlen(finfo.name) > 19)
		str += string(finfo.name, 19);
	else
		str += finfo.name + string(19 - strlen(finfo.name), ' ');
	str += char(179);

	/*size*/

	string size;
	if (finfo.size >= 1000 * 1000 * 1000)  // > 1 gb
		size = std::to_string(finfo.size / (1024 * 1024 * 1024)) + ',' + std::to_string(finfo.size % (1024 * 1024 * 1024) / 1024 / 1024 *100 / 1024) + 'G';
	else if (finfo.size >= 1000 * 1000)  // > 1 mb < 1 gb
		size = std::to_string(finfo.size / (1024 * 1024)) + ',' + std::to_string(finfo.size % (1024 * 1024) * 100 / (1024 * 1024)) + 'M';
	else if (finfo.size >= 1000)  // > 1 kb < 1 mb
		size = std::to_string(finfo.size / 1024) + ',' + std::to_string(finfo.size % 1024 * 100 / 1024) + 'K';
	else // < 1 kb
		size = std::to_string(finfo.size) + 'B';

	if (size.size() > 7)
		throw string("lenght of str:size > 7 : ") + size;

	if (size.size() < 7)
		size.insert(0, 7 - size.size(), ' ');

	str += size + char(179);

	/*date*/
	tm t;
	localtime_s(&t, &finfo.time_write);
	if (t.tm_mday < 10)
		str += '0';
	str += std::to_string(t.tm_mday) + '.';
	if (t.tm_mon < 9)
		str += '0';
	str += std::to_string(t.tm_mon + 1) + '.' + std::to_string(t.tm_year + 1900);
	str += char(179);


}
示例#12
0
void _formatTime(std::ostringstream &ss, time_t t)
{
	struct tm tm1;
	char szTime[24];
#ifdef _WIN32
	localtime_s(&tm1, &t);
	sprintf_s(szTime, 24, "%04d-%02d-%02d %02d:%02d:%02d",
		tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday,
		tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
#else
	localtime_r(&t, &tm1);
	snprintf(szTime, 24, "%04d-%02d-%02d %02d:%02d:%02d",
		tm1.tm_year + 1900, tm1.tm_mon + 1, tm1.tm_mday,
		tm1.tm_hour, tm1.tm_min, tm1.tm_sec);
#endif
	
	ss << szTime;
}
示例#13
0
void OnTimer(void* vp)
{
	time_t t;
	CClock* p = (CClock*)vp;
	// 시계를 멈추기전까지 계속 현재시간을 구한다.
	while (p->bStop != FALSE)
	{
		Sleep(1000);
		t = time(NULL);
		//p->now = *localtime(&t);
		localtime_s(&(p->now), &t);
		// 매1분마다 콜백함수호출
		if (p->now.tm_sec == 0)
		{
			if (p->m_cb) p->m_cb();
		}
	}
}
示例#14
0
const char* CFileListView::ConvertTime( const time_t* pFileTime )
{
	static char szBuffer[1024];
	tm localTime;

	assert(pFileTime != NULL);

	localtime_s(&localTime, pFileTime);

	sprintf_s(szBuffer, 1024, "%d/%d/%d %.2d:%.2d",
		localTime.tm_year + 1900,
		localTime.tm_mon + 1,
		localTime.tm_mday,
		localTime.tm_hour,
		localTime.tm_min);

	return szBuffer;
}
示例#15
0
STLWriter::STLWriter() : filename_(""),
                         filedir_(""), 
                         isBinaryMode_(false)
{
     time_t t = time(0);
    struct tm* n = new tm();
    localtime_s(n, &t);

    // Use the time of construction 
    // for a unique filename
    filename_ = (n->tm_year + 1900) + 
                (n->tm_mon + 1) +
                n->tm_mday + 
                "_" +
                n->tm_hour + 
                n->tm_min + 
                n->tm_sec;
}
bool ClockTime::checkOverdueTime() {
	bool hasElapsed;
	struct tm today;
	time_t currentTime = time(ZERO);	// get local time
	int hr  = _time / TIME_DIVISOR,
		min = _time % TIME_DIVISOR;

	localtime_s( &today, &currentTime); // update tm struct to be local date and time

	if( hr < today.tm_hour ) {
		hasElapsed = true;
	} else if ( hr == today.tm_hour && min <= today.tm_min) {
		hasElapsed = true; 
	} else{
		hasElapsed = false;
	}
	return hasElapsed;
}
示例#17
0
文件: common.c 项目: ablock/canboat
static int logBase(LogLevel level, const char * format, va_list ap)
{
  struct _timeb timebuffer;
  struct tm tm;
  char strTmp[60];

  if (level > logLevel)
  {
    return 0;
  }

  _ftime_s(&timebuffer);
  localtime_s(&tm, &timebuffer.time);
  strftime(strTmp, 60, "%Y-%m-%d %H:%M:%S", &tm);
  fprintf(stderr, "%s %s,%3.3d [%s] ", logLevels[level], strTmp, timebuffer.millitm, progName);

  return vfprintf(stderr, format, ap);
}
void RaceStandingsPlugin::Log(const char *msg)
{
  FILE *fo;
  time_t curtime;
  struct tm localtime;
  char timestamp[26];

  fo = fopen( RACE_STANDINGS_LOG_FILENAME, "a" );
  if( fo != NULL )
  {
	curtime = time(NULL);
	localtime_s(&localtime, &curtime);
	asctime_s(timestamp, 26, &localtime);
	timestamp[24] = 0;
    fprintf( fo, "[%s] %s\n", timestamp, msg );
    fclose( fo );
  }
}
示例#19
0
static void FormatAt(char* buffer, int32_t len, time_t now)
{
#if 0
    struct tm timinfo;

    if (now == 0)
    {
        now = time(0);
    }
#endif

#if defined(linux) || defined(__linux) || defined(__linux__)
    strftime(buffer, len, "%F %T", localtime_r(&now, &timinfo));
#elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
    localtime_s(&timinfo, &now);
    strftime(buffer, len, "%F %T", &timinfo);
#endif
}
示例#20
0
文件: logger.cpp 项目: tacow/test
bool MsgLogger::Init(const char* prefix, const char* logPath) {
    m_prefix = prefix;
    m_logPath = logPath;
    m_logFileName = m_logPath + "/" + m_prefix + ".log";
    m_historyFileNamePattern = m_logPath + "/" + m_prefix + "_%Y%m%d%H%M%S.log";

    time_t ttNow = time(NULL);
    time_t ttNowAdj = ttNow + TZ_ADJUST;
    m_ttLogDay = ttNowAdj / (24 * 3600);

    tm tmNow;
    localtime_s(&tmNow, &ttNow);
    char strLogDay[256];
    strftime(strLogDay, 256, "%Y-%m-%d", &tmNow);
    m_strLogDay = strLogDay;

    return DoDivide();
}
示例#21
0
void FSTimeLimiter(int iYear, int iMonth, int iDay)
{
	time_t secs=time(0);
#if defined (WIN32)
	tm now_s;
	localtime_s(&now_s, &secs);
	const tm *now=&now_s;
#else
	tm *now=localtime(&secs);
#endif
	if (now->tm_year+1900 > iYear) throw CFSException();
	if (now->tm_year+1900 == iYear) {
		if (now->tm_mon+1 > iMonth) throw CFSException();
		if (now->tm_mon+1 == iMonth) {
			if (now->tm_mday >= iDay) throw CFSException();
		}
	}
}
示例#22
0
void Logger::saveSession(FILE* session){

	fprintf(session,"## Session ID \n");

	fprintf(session,"%d \n",m_Session_id);
	fprintf(session,"# Session Date and Time \n");

	struct tm Today;
	time_t now;

	time(&now);
	
	localtime_s(&Today, &now);

	saveTimeDate(session, &Today);
	
	fprintf(session,"\n");
}
示例#23
0
int main(void)
{
    struct tm ptm;
    time_t t = time(NULL);
    ptm = *gmtime(&t);
    printf("UTC:   %s", asctime(&ptm));
    ptm = *localtime(&t);
    printf("local: %s", asctime(&ptm));

#ifdef __STDC_LIB_EXT1__
    struct tm buf;
    char str[26];
    asctime_s(str, sizeof str, gmtime_s(&t, &buf));
    printf("UTC:   %s", str);
    asctime_s(str, sizeof str, localtime_s(&t, &buf));
    printf("local: %s", str);
#endif
}
示例#24
0
   const std::string toDate(const uint64 tt)
   {
      if (0 == tt)
      {
         DateTime dt;
         return dt.toDate();
      }

      char buf[64] = { 0 };
      struct tm tm_;
#if defined(_WINDOWS) || defined(_WIN32)
      localtime_s(&tm_, (time_t*)&tt);
#else
      tm_ = localtime_r(&tt);
#endif
      strftime(buf, 64, "%Y-%m-%d", &tm_);
      return buf;
   }
示例#25
0
   void DateTime::_setTime(const uint64 tt)
   {
      _millis = (time_t)tt;

      struct tm tm_;
#if defined(_WINDOWS) || defined(_WIN32)
      localtime_s(&tm_, &_millis);
#else
      tm_ = localtime_r(&tt);
#endif
      _year = tm_.tm_year + 1900;
      _mon  = tm_.tm_mon + 1;
      _day  = tm_.tm_mday;
      _hour = tm_.tm_hour;
      _min  = tm_.tm_min;
      _sec  = tm_.tm_sec;
      _wday = tm_.tm_wday;
   }
/**
* Description:  SetRangeField().    设置Range头域
* @param  [in]  ulStartTime         起始时间
* @param  [in]  bRelativeTime   是否为相对时间
* @param  [io]  strRange        设置后的字符串
* @return       long.   返回码
*/
long CRtspPacket::SetRangeField
(
    IN  unsigned long   ulStartTime,
    IN  BOOL            bRelativeTime,
    IO  string&         strRange
)const
{
    //开始时间转换为字符串,最大长度不会超过32字节
    char szStartTime[32] = {0};
    
    if (bRelativeTime)
    {
        (void)snprintf(szStartTime, sizeof(szStartTime) - 1, "%u-", ulStartTime);

        //Range使用npt相对时间
        strRange += "Range:npt=";
    }
    else
    {
        time_t tStartTime = ulStartTime;
        
        //localtime返回NULL的条件:  Before midnight, January 1, 1970.  After 03:14:07, January 19, 2038,
        struct tm _tm;
		memset(&_tm, 0, sizeof(tm));
		localtime_s(&_tm, &tStartTime);
        
        (void)snprintf(szStartTime, sizeof(szStartTime) - 1, 
                        "%04d%02d%02dT%02d%02d%02dZ-", 
                        _tm.tm_year + 1900, 
                        _tm.tm_mon + 1, 
                        _tm.tm_mday, 
                        _tm.tm_hour, 
                        _tm.tm_min, 
                        _tm.tm_sec);

        //Range使用clock绝对时间
        strRange += "Range:clock=";
    }
    
    strRange += szStartTime;
    strRange += RTSP::CRLF;

    return RTSP::RET_CODE_OK; 
}
示例#27
0
文件: z_log.cpp 项目: jtalz/znetlib
size_t zLog::print(const string& status, const string& classname, const list<string>& buf) const
{
#if defined(_WIN32)
 return write(buf);
#else
#if defined(__GNUG__) || defined(__CYGWIN__) || defined(__linux__)
 if(buf.size() == 0) return 0;
 string q;
 time_t ltime = ::time(NULL);
 struct tm tmtime;
#if defined(_WIN32)
 localtime_s(&tmtime,&ltime);
#else
#if defined(__GNUG__) || defined(__CYGWIN__) || defined(__linux__)
 localtime_r(&ltime, &tmtime);
#endif // _WIN32
#endif // __GNUG__
 q+='[';
 if(tmtime.tm_mday < 10) q+='0';
 q+=ZNSTR::toString(static_cast<int>(tmtime.tm_mday));
 q+='/';
 if(tmtime.tm_mon < 10) q+='0';
 q+=ZNSTR::toString(static_cast<int>(tmtime.tm_mon));
 q+='/';
// if(tmtime.tm_year < 10) q+='0';
 q+=ZNSTR::toString(static_cast<int>(tmtime.tm_year));
 q+=' ';

 if(tmtime.tm_hour < 10) q+='0';
 q+=ZNSTR::toString(static_cast<int>(tmtime.tm_hour));
 q+=':';
 if(tmtime.tm_min < 10) q+='0';
 q+=ZNSTR::toString(static_cast<int>(tmtime.tm_min));
 q+=':';
 if(tmtime.tm_sec < 10) q+='0';
 q+=ZNSTR::toString(static_cast<int>(tmtime.tm_sec));

 q+="] "+status+' '+classname+' ';
 string s;
 for(list<string>::const_iterator k=buf.begin(); k != buf.end(); ++k) { s+=(q+*k); }
 return write(s);
#endif // _WIN32
#endif // __GNUG__
};
示例#28
0
const char * timeStamp::TimeStamp(char * const buffer, int bufsize, bool useColons)
{
	const char* const format = useColons ? "%F %T." : "%F %H-%M-%S.";

	const int millisize = 5;
	char millibuf[millisize];
	struct _timeb timebuffer;
	_ftime64_s(&timebuffer);
	unsigned short millitime = timebuffer.millitm;
	sprintf_s(millibuf, millisize, "%03d.", millitime);

	time_t rawTime;
	time(&rawTime);
	struct tm timeInfo;
	localtime_s(&timeInfo, &rawTime);
	strftime(buffer, bufsize, format, &timeInfo);
	strcat_s(buffer, bufsize, millibuf);
	return buffer;
}
示例#29
0
CTime::operator FILETIME() const
{
	FILETIME ft;
	FILETIME localTime;
	SYSTEMTIME st;
	struct tm Time;
	localtime_s(&Time,&m_time);
	st.wYear=Time.tm_year+1900;
	st.wMonth=Time.tm_mon+1;
	st.wDayOfWeek=Time.tm_wday;
	st.wDay=Time.tm_mday;
	st.wHour=Time.tm_hour;
	st.wMinute=Time.tm_min;
	st.wSecond=Time.tm_sec;
	st.wMilliseconds=msec;
	SystemTimeToFileTime(&st,&localTime);
	LocalFileTimeToFileTime(&localTime,&ft);
	return ft;
}
示例#30
0
string Store::currentYear() {

	time_t rawtime;
	time(&rawtime);

	tm now;
	localtime_s(&now, &rawtime);

	int nowYear = 1900 + (&now)->tm_year;  
	
	ostringstream convert;   // stream used for the conversion

	convert << nowYear; 

	string nowYearstr = convert.str();

	return nowYearstr;

}