예제 #1
0
파일: logging.c 프로젝트: tgreaves/ilona
void do_sys_log ( struct sys_config *sc, char *format, ... ) {

   char newbuf [512] ;
   va_list msg ;
   FILE *file ;
   time_t dat ;

   va_start (msg, format) ;
   vsprintf(newbuf, format, msg) ;
   va_end (msg) ;

   #ifdef PRINT_SYSLOG
	printf("[%s %s] %s\n", DateToString(&dat), TimeToString(&dat), newbuf);
   #endif

   if ( sc->systemlog[0] != '\0' ) {

      if ( file = fopen (sc->systemlog, "a" ) ) {

         dat = time (NULL) ;

         fprintf (file, "[%s %s] %s\n",  DateToString(&dat), TimeToString(&dat), newbuf) ;

         fclose (file) ;

      }

   }

}
예제 #2
0
파일: eit.c 프로젝트: stesee/open7x0.org
cTDT::cTDT(const u_char *Data)
:SI::TDT(Data, false)
{
  CheckParse();

  time_t sattim = getTime();
  time_t loctim = time(NULL);

  int diff = abs(sattim - loctim);
  if (diff > 2) {
     mutex.Lock();
     if (abs(diff - lastDiff) < 3) {
        isyslog("System Time = %s (%ld)", *TimeToString(loctim), loctim);
        isyslog("Local Time  = %s (%ld)", *TimeToString(sattim), sattim);
        if (stime(&sattim) < 0){
				char __errorstr[256];
				strerror_r(errno,__errorstr,256);
				__errorstr[255]=0;
           esyslog("ERROR while setting system time: %s",__errorstr);
			  }
        }
     lastDiff = diff;
     mutex.Unlock();
     }
}
예제 #3
0
//---------------------------------------------------------------------------
//                               SERVER EVENTS TEXT
//---------------------------------------------------------------------------
static BaseString SenderText(TSrvEvent &Event)
{
  if (Event.EvtSender!=0)
    return TimeToString(Event.EvtTime)+" ["+IpAddressToString(Event.EvtSender)+"] ";
  else
    return TimeToString(Event.EvtTime)+" Server ";
}
예제 #4
0
void CGameServDlg::UpdateTimers()
{
	DWORD timeCur;

	if(!IsRunning())
		return;

	timeCur = timeGetTime();

	// Update the server time...

	m_timeServerRunning = timeCur - m_timeServerStart;
	if ((m_timeServerLast / 1000) != (m_timeServerRunning / 1000))
	{
		SetDlgItemText(IDC_SERVER_TIME, TimeToString(m_timeServerRunning));
		m_timeServerLast = m_timeServerRunning;
	}


	// Update the game/level time...

	m_timeLevelRunning = timeCur - m_timeLevelStart;
	if ((m_timeLevelLast / 1000) != (m_timeLevelRunning / 1000))
	{
		SetDlgItemText(IDC_GAME_TIME, TimeToString(m_timeLevelRunning));
		m_timeLevelLast = m_timeLevelRunning;
	}


	// Remove any update messages in the queue...

	RemoveMessage(WM_TIMER, 500);
}
예제 #5
0
void TProjectSettings::Init()
{
	// Tell parent we have been constructed
	m_Parent->m_ProjectSettings = true;
		
	// Get dialog items	
	m_RealTimeButton 	= (BRadioButton *)FindView("RealTime");
	m_24FPSButton 		= (BRadioButton *)FindView("24FPS");
	m_25FPSButton 		= (BRadioButton *)FindView("25FPS");
	m_2997FPSButton 	= (BRadioButton *)FindView("2997FPS");
	m_30FPSButton 		= (BRadioButton *)FindView("30FPS");
		
	m_StartTime = (BTextControl *)FindView("StartTime");
	m_Duration 	= (BTextControl *)FindView("Duration");
	m_EndTime 	= (BTextControl *)FindView("EndTime");
	
	// Set up time values
	char timeStr[256];
	TimeToString(m_CueSheet->StartTime(), m_CueSheet->GetTimeFormat(), timeStr, false);
	m_StartTime->SetText(timeStr);
	
	TimeToString(m_CueSheet->Duration(), m_CueSheet->GetTimeFormat(), timeStr, false);
	m_Duration->SetText(timeStr);
	
	TimeToString( m_CueSheet->Duration() - m_CueSheet->StartTime(), m_CueSheet->GetTimeFormat(), timeStr, false);
	m_EndTime->SetText(timeStr);
	
	// Set to current project settings
	m_TimeFormat = GetCurrentTimeFormat();
	switch(m_TimeFormat)
	{
		//case B_TIMECODE_30_DROP_2:
		//	m_RealTimeButton->SetValue(1);
		//	break;
			
		case B_TIMECODE_24:
			m_24FPSButton->SetValue(1);
			break;
			
		case B_TIMECODE_25:
			m_25FPSButton->SetValue(1);
			break;
			
		case B_TIMECODE_30_DROP_2:
			m_2997FPSButton->SetValue(1);
			break;
			
		case B_TIMECODE_30:
			m_30FPSButton->SetValue(1);
			break;
	
		default:
			m_RealTimeButton->SetValue(1);
			break;
	}
		
	m_StartTime->MakeFocus(true);		
}
예제 #6
0
void RandKeysUtil::SetStates()
	{
	if (doTime) {
		iPosTime->Enable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_POSTIMELABEL),TRUE);
		iNegTime->Enable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_NEGTIMELABEL),TRUE);
	} else {
		iPosTime->Disable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_POSTIMELABEL),FALSE);
		iNegTime->Disable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_NEGTIMELABEL),FALSE);
		}

	if (doVal) {
		iPosVal->Enable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_POSVALLABEL),TRUE);
		iNegVal->Enable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_NEGVALLABEL),TRUE);
	} else {
		iPosVal->Disable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_POSVALLABEL),FALSE);
		iNegVal->Disable();
		EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_NEGVALLABEL),FALSE);
		}

	switch (iu->GetMajorMode()) {
		case TVMODE_EDITKEYS:
		case TVMODE_EDITFCURVE:
			SetDlgItemText(hWnd,IDC_RANDKEYS_TEXT,
				GetString(IDS_RANDKEYS_KEYTEXT));
			EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_APPLY),TRUE);
			break;

		case TVMODE_EDITTIME: {
			Interval iv = iu->GetTimeSelection();
			TSTR buf, start, end;
			TimeToString(iv.Start(),start);
			TimeToString(iv.End(),end);
			buf.printf(GetString(IDS_RANDKEYS_TIMETEXT),start,end);
			SetDlgItemText(hWnd,IDC_RANDKEYS_TEXT,buf);
			EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_APPLY),TRUE);
			break;
			}

		case TVMODE_EDITRANGES:
		case TVMODE_POSRANGES:
			SetDlgItemText(hWnd,IDC_RANDKEYS_TEXT,_T(""));
			EnableWindow(GetDlgItem(hWnd,IDC_RANDKEYS_APPLY),FALSE);
			break;
		
		}
	}
예제 #7
0
/*
** Returns the time as string.
**
*/
const WCHAR* CMeasureTime::GetStringValue()
{
	static WCHAR tmpSz[MAX_LINE_LENGTH];
	struct tm today;

	tmpSz[0] = 0;

	SYSTEMTIME sysToday;
	FILETIME ftToday;
	ftToday.dwHighDateTime = m_Time.HighPart;
	ftToday.dwLowDateTime = m_Time.LowPart;

	FileTimeToSystemTime(&ftToday, &sysToday);

	today.tm_isdst = 0;
	today.tm_hour = sysToday.wHour;
	today.tm_mday = sysToday.wDay;
	today.tm_min = sysToday.wMinute;
	today.tm_mon = sysToday.wMonth - 1;
	today.tm_sec = sysToday.wSecond;
	today.tm_wday = sysToday.wDayOfWeek;
	today.tm_yday = GetYearDay(sysToday.wYear, sysToday.wMonth, sysToday.wDay);
	today.tm_year = sysToday.wYear - 1900;

	// Create the string
	if (!m_Format.empty())
	{
		const WCHAR* format = m_Format.c_str();
		if (_wcsicmp(L"locale-time", format) == 0)
		{
			GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
		}
		else if (_wcsicmp(L"locale-date", format) == 0)
		{
			GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
		}
		else
		{
			TimeToString(tmpSz, MAX_LINE_LENGTH, format, &today);
		}
	}
	else
	{
		TimeToString(tmpSz, MAX_LINE_LENGTH, L"%H:%M:%S", &today);
	}

	return CheckSubstitute(tmpSz);
}
예제 #8
0
nglString TimeLabel::GetLength()
{
  uint64 length = mLengthAttrib.Get();
  double seconds = (double)length / mSampleRate;
  nglString res = TimeToString(seconds);
  return res;
}
예제 #9
0
nglString TimeLabel::GetPosition()
{
  uint64 position = mPosAttrib.Get();
  double seconds = (double)position / mSampleRate;
  nglString res = TimeToString(seconds);
  return res;
}
예제 #10
0
void Scheduler::AddItem(boost::shared_ptr<Schedule> item)
{
	LOG_AM_TRACE("Entering function %s", __FUNCTION__);

	LOG_AM_DEBUG(
		"Adding [Activity %llu] to start at %llu (%s)",
		item->GetActivity()->GetId(),
		(unsigned long long)item->GetNextStartTime(),
		TimeToString(item->GetNextStartTime(), !item->IsLocal()).c_str());

	bool updateWake = false;

	if (item->IsLocal()) {
		m_localQueue.insert(*item);

		if (m_localQueue.iterator_to(*item) == m_localQueue.begin()) {
			updateWake = true;
		}
	} else {
		m_queue.insert(*item);

		if (m_queue.iterator_to(*item) == m_queue.begin()) {
			updateWake = true;
		}
	}

	if (updateWake) {
		DequeueAndUpdateTimeout();
	}
}
예제 #11
0
/**
 * @brief Dumps contest results
 *
 * @param type The type of the contest to dump
 */
void CTestContest::Dump(const CContestMgr::TType type) const
{
    CContestMgr::CResult result = _contestMgr.Result(type, true);
    const CPointGPSArray &array = result.PointArray();
    unsigned distance = 0;
    if(array.size()) {
        bool triangle = (type == CContestMgr::TYPE_OLC_FAI || type == CContestMgr::TYPE_OLC_FAI_PREDICTED);
        for(unsigned i=0; i<array.size() - 1; i++) {
            if((i==0 || i==array.size() - 2) && triangle)
                continue;
            distance += array[i].Distance(array[i+1]);
        }
        if(triangle)
            distance += array[3].Distance(array[1]);
    }

    std::cout << std::endl;
    std::wstring typeStr = CContestMgr::TypeToString(type);
    std::cout << "Contest '" << std::string(typeStr.begin(), typeStr.end()) << "':" << std::endl;
    std::cout << " - Distance: " << result.Distance() << " (error: " << (int)distance - (int)result.Distance() << ")" << std::endl;
    std::cout << " - Score: " << result.Score() << std::endl;
    std::cout << " - Predicted: " << result.Predicted() << std::endl;
    for(CPointGPSArray::const_iterator it=result.PointArray().begin(); it!=result.PointArray().end(); ++it)
        std::cout << " - " << TimeToString(it->Time()) << std::endl;

    _kml.Dump(result);
}
예제 #12
0
파일: time.hpp 프로젝트: kkzhou/mytools
    inline int CurrentTimeString(std::string &time_str) {

	struct timeval t;
	gettimeofday(&t, 0);
	int ret = TimeToString(t, time_str);
	return ret;
    };
예제 #13
0
void TVideoEditorText::MessageReceived(BMessage* theMessage)
{
	switch( theMessage->what)
	{
	//      Time is inferred from point.  This is used during a mouse over the cue sheet
	case UPDATE_TIMELINE_MSG:
	{
		int64 theTime;

		if ( theMessage->FindInt64("TheTime", &theTime) == B_OK) {

			// Don't allow negative times to slip through
			if (theTime >= 0) {
				TimeToString(theTime, GetCurrentTimeFormat(), fText, false);
				Draw(Bounds());
			}
		}
	}
	break;

	default:
		break;

	}
}
예제 #14
0
파일: logging.c 프로젝트: tgreaves/ilona
void do_bot_log ( struct Bot *b, char *format, ... ) {

   char newbuf [512] ;
   va_list msg ;
   FILE *file ;
   time_t dat ;

   va_start (msg, format) ;
   vsprintf(newbuf, format, msg) ;
   va_end (msg) ;

	/* printf("[%s %s] %s\n", DateToString(&dat), TimeToString(&dat), newbuf); */

   if ( b->botlog[0] != '\0' ) {

      if ( file = fopen (b->botlog, "a" ) ) {

         dat = time (NULL) ;

         fprintf (file, "[%s %s] %s\n",  DateToString(&dat), TimeToString(&dat), newbuf) ;

         fclose (file) ;

      }

   }

}
void isiTapResults::fillResultsTable()
	{
	CWfdisc *wfd;

	QString sTime, qSta, qChan, qSpS;
	int nRow = 0;

	IDC_CHAN->insertRows(0, wfdarr.count());

	for (wfd=wfdarr.first();wfd;wfd=wfdarr.next(),++nRow) 
		{
		qSta=wfd->wfd.sta;
		qChan=wfd->wfd.chan;
		if(wfd->wfd.smprate>0)
			{
			qSpS.sprintf("%.3f",wfd->wfd.smprate);
			}
		else
			{
			qSpS = "-";
			}
		IDC_CHAN->setText(nRow,   0, qSta);
		IDC_CHAN->setText(nRow,   1, qChan);
		IDC_CHAN->setText(nRow,   2, qSpS);
		
		if(wfd->wfd.time>0)
			{
			sTime= TimeToString(wfd->wfd.time, nTimeFormat);
			}
		else
			{
			sTime="";
			}
		IDC_CHAN->setText(nRow, 3, sTime);
		if(wfd->wfd.endtime>0)
			{
			sTime = TimeToString(wfd->wfd.endtime, nTimeFormat);
			}
		else
			{
			sTime="";
			}
		IDC_CHAN->setText(nRow, 4, sTime);

		}
	adjustTableColumnWidth();
	}
예제 #16
0
void Benchmark(Test::TestClass suites, double t, double hertz)
{
	g_allocatedTime = t;
	g_hertz = hertz;

	AddHtmlHeader();

	g_testBegin = ::time(NULLPTR);

	if (static_cast<int>(suites) == 0 || static_cast<int>(suites) > TestLast)
		suites = Test::All;

	// Unkeyed algorithms
	if (suites & Test::Unkeyed)
	{
		std::cout << "\n<BR>";
		Benchmark1(t, hertz);
	}

	// Shared key algorithms
	if (suites & Test::SharedKey)
	{
		std::cout << "\n<BR>";
		Benchmark2(t, hertz);
	}

	// Public key algorithms
	if (suites & Test::PublicKey)
	{
		std::cout << "\n<BR>";
		Benchmark3(t, hertz);
	}

	g_testEnd = ::time(NULLPTR);

	{
		StreamState state(std::cout);
		std::cout << "\n<P>Throughput Geometric Average: " << std::setiosflags(std::ios::fixed);
		std::cout << std::exp(g_logTotal/(g_logCount > 0.0f ? g_logCount : 1.0f)) << std::endl;
	}

	std::cout << "\n<P>Test started at " << TimeToString(g_testBegin);
	std::cout << "\n<BR>Test ended at " << TimeToString(g_testEnd);
	std::cout << std::endl;

	AddHtmlFooter();
}
예제 #17
0
void TCueSheetTimeView::Draw(BRect updateRect)
{
	// Set up environment
	PushState();
	
	const BRect bounds = Bounds();
	
	BPoint startPt, endPt;
	
	// Draw TimeRect frame
	SetHighColor(kLightGrey);
	FillRect(bounds);
	
	//	Draw black outline
	SetHighColor(kBlack);
	startPt.Set(bounds.left, bounds.top);
	endPt.Set(bounds.left, bounds.bottom);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.right, bounds.top);
	endPt.Set(bounds.right, bounds.bottom);
	StrokeLine(startPt, endPt);
	
	
	//	Draw shadow
	SetHighColor(kMediumGrey);
	startPt.Set(bounds.right-1, bounds.top);
	endPt.Set(bounds.right-1, bounds.bottom);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.right-1, bounds.bottom);
	endPt.Set(bounds.left+1, bounds.bottom);
	StrokeLine(startPt, endPt);
	
	//	Draw highlight	
	SetHighColor(kWhite);
	startPt.Set(bounds.left+1, bounds.bottom - 2);
	endPt.Set(bounds.left+1, bounds.top);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.left+1, bounds.top);
	endPt.Set(bounds.right-2, bounds.top);
	StrokeLine(startPt, endPt);

	// Draw cue sheet start time
	BFont font; 
   	GetFont(&font); 
	SetFont(be_bold_font);   
   	SetHighColor(kBlack);
   	
	BPoint 	textPt;
	char 	timeStr[256];
	int32 	startTime = m_CueSheetWindow->GetCueSheetView()->StartTime();
	textPt.Set(bounds.left + 9, bounds.top + 16);
	TimeToString(startTime, m_CueSheetWindow->GetCueSheetView()->GetTimeFormat(), timeStr, FALSE);		
	DrawString(timeStr, textPt);
	
	// Restore environment
	PopState();
}
예제 #18
0
파일: log.hpp 프로젝트: kkzhou/mytools
	int CurrentTimeString(std::string &time_str) {

	    ENTER_LOG;
	    struct timeval t;
	    gettimeofday(&t, 0);
	    int ret = TimeToString(t, time_str);
	    LEAVE_LOG;
	    return ret;
	};
예제 #19
0
파일: util.hpp 프로젝트: kkzhou/kknf
	static int CurrentTimeString(std::string &time_str) {

	    time_t curtime = time(0);
	    if (curtime == -1) {
		return -1;
	    }
	    int ret = TimeToString(curtime, time_str);
	    return ret;
	};
예제 #20
0
	void OnlineSVR::Import(char* Filename, Matrix<double>** AngularPositions, Matrix<double>** MotorCurrents, Matrix<double>** AppliedVoltages)
	{	
		// Open the file
		ifstream File (Filename, ios::in);
		if (!File) {
			cerr << "Error. File not found." << endl;
			return;
		}

		// Time
		time_t StartTime = time(NULL);
		cout << "Starting import new data..." << endl;
		int RowsNumber = 0;

		try {

			(*AngularPositions) = new Matrix<double>();
			(*MotorCurrents) = new Matrix<double>();
			(*AppliedVoltages) = new Matrix<double>();
			Vector<double>* Line;
			char X[80];
			double X1, X2, X3, X4;

			File >> X >> X;
			while (!File.eof()) {
				RowsNumber ++;
				// Import Angular Position
				File >> X1 >> X >> X2 >> X >> X3 >> X >> X4 >> X >> X >> X;
				Line = new Vector<double>(4);
				Line->Add(X1); Line->Add(X2); Line->Add(X3); Line->Add(X4);
				(*AngularPositions)->AddRowRef(Line);
				// Import Motor Currents
				File >> X1 >> X >> X2 >> X >> X3 >> X >> X4 >> X >> X >> X;
				Line = new Vector<double>(4);
				Line->Add(X1); Line->Add(X2); Line->Add(X3); Line->Add(X4);
				(*MotorCurrents)->AddRowRef(Line);
				// Import Applied Voltages
				File >> X1 >> X >> X2 >> X >> X3 >> X >> X4 >> X >> X >> X;
				Line = new Vector<double>(4);
				Line->Add(X1); Line->Add(X2); Line->Add(X3); Line->Add(X4);
				(*AppliedVoltages)->AddRowRef(Line);
			}
		}
		catch (...) {
			cerr << "Error. The file is probably corrupted." << endl;
		}

		// Close the file
		File.close();

		// Final Message
		time_t EndTime = time(NULL);
		long ImportTime = static_cast<long>(EndTime-StartTime);
		char Line[80];
		sprintf(Line, "\nImported %d samples correctly in %s.\n", RowsNumber, TimeToString(ImportTime));	
		cout << Line << endl;
	}
예제 #21
0
std::string ProgressTimer::GetProgressMessage(double progress,
                                              bool bIncludeElapsed,
                                              bool bIncludeRemaining) const {

  const double miliSecs = Elapsed();
  std::string result;

  if (bIncludeElapsed) {
    if (!result.empty()) result += " "; 
    result += "Elapsed: " + TimeToString(miliSecs);
  }
  if (bIncludeRemaining && progress > 0.0) {
    if (!result.empty()) result += " "; 
    result += "Remaining: " + TimeToString(miliSecs * (1.0-progress)/progress);
  }

  return result;
}
예제 #22
0
CString CDownloadWithSources::GetSourceURLs(CList< CString >* pState, int nMaximum, PROTOCOLID nProtocol, CDownloadSource* pExcept) const
{
	CQuickLock pLock( Transfers.m_pSection );

	CString strSources;

	for ( POSITION posSource = GetIterator() ; posSource ; )
	{
		CDownloadSource* pSource = GetNext( posSource );

		if ( pSource != pExcept && pSource->m_bPushOnly == FALSE &&
			 ( ( pSource->m_nFailures == 0 && pSource->m_bReadContent ) || nProtocol == PROTOCOL_NULL ) &&
			 ( pSource->m_bSHA1 || pSource->m_bTiger || pSource->m_bED2K || pSource->m_bBTH || pSource->m_bMD5 ) &&
			 ( pState == NULL || pState->Find( pSource->m_sURL ) == NULL ) )
		{
			// Only return appropriate sources
			if ( ( nProtocol == PROTOCOL_HTTP ) && ( pSource->m_nProtocol != PROTOCOL_HTTP ) ) continue;
			if ( ( nProtocol == PROTOCOL_G1 ) && ( pSource->m_nGnutella != 1 ) ) continue;
			//if ( bHTTP && pSource->m_nProtocol != PROTOCOL_HTTP ) continue;

			if ( pState != NULL ) pState->AddTail( pSource->m_sURL );

			if ( nProtocol == PROTOCOL_G1 )
			{
				if ( ! strSources.IsEmpty() )
					strSources += ',';
				strSources += CString( inet_ntoa( pSource->m_pAddress ) );
				CString strURL;
				strURL.Format( _T("%hu"), pSource->m_nPort );
				strSources += ':' + strURL;
			}
			else if ( pSource->m_sURL.Find( _T("Zhttp://") ) >= 0 ||
				pSource->m_sURL.Find( _T("Z%2C http://") ) >= 0 )
			{
				// Ignore buggy URLs
				TRACE( _T("CDownloadWithSources::GetSourceURLs() Bad URL: %s\n"), pSource->m_sURL );
			}
			else
			{
				CString strURL = pSource->m_sURL;
				strURL.Replace( _T(","), _T("%2C") );

				if ( ! strSources.IsEmpty() ) strSources += _T(", ");
				strSources += strURL;
				strSources += ' ';
				strSources += TimeToString( &pSource->m_tLastSeen );
			}

			if ( nMaximum == 1 )
				break;
			else if ( nMaximum > 1 )
				nMaximum --;
		}
	}

	return strSources;
}
예제 #23
0
void CBoxHttpResponse::put_ExpiresAbsolute(DATE dateExpires)
{
	SYSTEMTIME st;
	CString strTime;

	VariantTimeToSystemTime(dateExpires, &st);
	TimeToString(st, strTime);

	m_pAccept->SetHeader(_T("Expires"), strTime);
}
예제 #24
0
	void OnlineSVR::Import(char* Filename, Matrix<double>** X, Vector<double>** Y)
	{	
		// Open the file
		ifstream File (Filename, ios::in);
		if (!File) {
			cerr << "Error. File not found." << endl;
			return;
		}

		// Time
		time_t StartTime = time(NULL);
		cout << "Starting import new data..." << endl;
		int RowsNumber, ColsNumber;

		try {

			// Reading the parameters		
			File >> RowsNumber >> ColsNumber;
			
			// Import the data
			(*X) = new Matrix<double>();
			(*Y) = new Vector<double>(RowsNumber);
			double Value;
			for (int i=0; i<RowsNumber; i++) {
				// Add Y
				File >> Value;
				(*Y)->Add(Value);
				// Add X
				Vector<double>* Line = new Vector<double>(ColsNumber-1);
				for (int j=0; j<ColsNumber-1; j++) {
					File >> Value;
					Line->Add(Value);
				}
				(*X)->AddRowRef(Line);
			}

		}
		catch (...) {
			cerr << "Error. The file is probably corrupted." << endl;
		}

		// Close the file
		File.close();

		// Final Message
		time_t EndTime = time(NULL);
		long ImportTime = static_cast<long>(EndTime-StartTime);
		char Line[80];
		char* ElapsedTime = TimeToString(ImportTime);
		sprintf(Line, "\nImported %d samples correctly in %s.\n", RowsNumber, ElapsedTime);
		delete ElapsedTime;
		cout << Line << endl;
	}
예제 #25
0
파일: util.hpp 프로젝트: kkzhou/kknf
	static int CurrentTimeString(std::string &time_str) {

	    ENTERING;
	    time_t curtime = time(0);
	    if (curtime == -1) {
		LEAVING2;
		return -1;
	    }
	    int ret = TimeToString(curtime, time_str);
	    LEAVING;
	    return ret;
	};
예제 #26
0
파일: eit.c 프로젝트: suborb/reelvdr
cTDT::cTDT(const u_char *Data)
:SI::TDT(Data, false)
{
  CheckParse();

  time_t sattim = getTime();
  time_t loctim = time(NULL);

  int diff = abs(sattim - loctim);
  if (diff > 2) {
     mutex.Lock();
     if (abs(diff - lastDiff) < 3) {
        isyslog("System Time = %s (%ld)", *TimeToString(loctim), loctim);
        isyslog("Local Time  = %s (%ld)", *TimeToString(sattim), sattim);
        if (stime(&sattim) < 0)
           esyslog("ERROR while setting system time: %m");
        }
     lastDiff = diff;
     mutex.Unlock();
     }
}
예제 #27
0
/*
** Updates the current time
**
*/
void CMeasureTime::UpdateValue()
{
	FillCurrentTime();

	if (!m_Format.empty())
	{
		// If there is some date format, parse the value from it instead
		WCHAR* tmpSz = new WCHAR[MAX_LINE_LENGTH];
		SYSTEMTIME sysToday;
		FILETIME ftToday;

		tmpSz[0] = 0;

		ftToday.dwHighDateTime = m_Time.HighPart;
		ftToday.dwLowDateTime = m_Time.LowPart;

		FileTimeToSystemTime(&ftToday, &sysToday);

		const WCHAR* format = m_Format.c_str();
		if (_wcsicmp(L"locale-time", format) == 0)
		{
			GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
		}
		else if (_wcsicmp(L"locale-date", format) == 0)
		{
			GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
		}
		else
		{
			struct tm today;
			today.tm_isdst = 0;
			today.tm_hour = sysToday.wHour;
			today.tm_mday = sysToday.wDay;
			today.tm_min = sysToday.wMinute;
			today.tm_mon = sysToday.wMonth - 1;
			today.tm_sec = sysToday.wSecond;
			today.tm_wday = sysToday.wDayOfWeek;
			today.tm_yday = GetYearDay(sysToday.wYear, sysToday.wMonth, sysToday.wDay);
			today.tm_year = sysToday.wYear - 1900;

			TimeToString(tmpSz, MAX_LINE_LENGTH, format, &today);
		}

		m_Value = wcstod(tmpSz, NULL);

		delete [] tmpSz;
	}
	else
	{
		m_Value = (double)(m_Time.QuadPart / 10000000);
	}
}
예제 #28
0
/** 
 * @brief Dumps contest results
 * 
 * @param type The type of the contest to dump
 */
void CTestContest::Dump(const CContestMgr::TType type) const
{
  const CContestMgr::CResult &result = _contestMgr.Result(type);
  
  std::cout << std::endl;
  std::cout << "Contest '" << CContestMgr::TypeToString(type) << "':" << std::endl;
  std::cout << " - Distance: " << result.Distance() << std::endl;
  std::cout << " - Score: " << result.Score() << std::endl;
  for(CPointGPSArray::const_iterator it=result.PointArray().begin(); it!=result.PointArray().end(); ++it)
    std::cout << " - " << TimeToString(it->Time()) << std::endl;
  
  _kml.Dump(result);
}
예제 #29
0
bool cShutdownHandler::DoShutdown(bool Force)
{
  dsyslog("DEBUG: DoShutdown called");
  time_t Now = time(NULL);
  cTimer *timer = Timers.GetNextActiveTimer();
  cPlugin *Plugin = cPluginManager::GetNextWakeupPlugin();

  time_t Next = timer ? timer->StartTime() : 0;
  time_t NextPlugin = Plugin ? Plugin->WakeupTime() : 0;
  if (NextPlugin && (!Next || Next > NextPlugin)) {
     Next = NextPlugin;
     timer = NULL;
     }
  time_t Delta = Next ? Next - Now : 0;

  if (Next && Delta < Setup.MinEventTimeout * 60) {
     if (!Force)
        return false;
     Delta = Setup.MinEventTimeout * 60;
     Next = Now + Delta;
     timer = NULL;
     dsyslog("reboot at %s", *TimeToString(Next));
     }

  if (Next && timer) {
     dsyslog("next timer event at %s", *TimeToString(Next));
     CallShutdownCommand(Next, timer->Channel()->Number(), timer->File(), Force);
     }
  else if (Next && Plugin) {
     CallShutdownCommand(Next, 0, Plugin->Name(), Force);
     dsyslog("next plugin wakeup at %s", *TimeToString(Next));
     }
  else
     CallShutdownCommand(Next, 0, "", Force); // Next should always be 0 here. Just for safety, pass it.

  return true;
}
예제 #30
0
void CBoxHttpResponse::put_Expires(long nTime)
{
	FILETIME ft;
	SYSTEMTIME st;
	CString strTime;
	CBoxObject<CBoxTimeCache::CTime> pTime;

	m_pAccept->m_time.GetTime(pTime);
	*(__int64*)&ft = pTime->m_time + (__int64)600000000 * nTime;
	pTime.Release();

	FileTimeToSystemTime(&ft, &st);
	TimeToString(st, strTime);

	m_pAccept->SetHeader(_T("Expires"), strTime);
}