예제 #1
0
bool TimeToFileTime(TimeStamp& time, LPFILETIME pFileTime)
{
	SYSTEMTIME sysTime;
	time.getTime(sysTime);

	// convert system time to local file time
	FILETIME localTime;
	if (!SystemTimeToFileTime((LPSYSTEMTIME)&sysTime, &localTime))
		return false;

	// convert local file time to UTC file time
	if (!LocalFileTimeToFileTime(&localTime, pFileTime))
		return false;

	return true;
}
예제 #2
0
void DialogEditTime::on_buttonBox_accepted()
{
    // workaround for missing leading zero bug: prepend a "0", if it is missing
    QString tStr = ui->lineEdit->text();
    QStringList helper = tStr.split(":");
    if(helper.first().length() == 1){
        tStr.prepend("0");
    }
    // end of workaround

    QTime t = QTime::fromString(tStr);
    qDebug() << "zeit: " << t.toString();

	TimeStamp* ts =0;

	if(myRun){// ignore runns with Nullpointer
		if(myTimeType == TT_START){
			if(myRun->getStartTimeID() == 0){ // if no TS exists, create a new one
				ts = new TimeStamp(0, t, TimeStamp::E);
				MainWindow::competition()->addTimeStamp(ts);
				ts->setRunID(myRun->getID());
				myRun->setStartTimeID(ts->getID());
			}else{
				ts = MainWindow::competition()->getTimeStamp(myRun->getStartTimeID());
			}
        }else{ // goal
			if(myRun->getGoalTimeID() == 0){ // if no TS exists, create a new one
				ts = new TimeStamp(0, t, TimeStamp::E);
				MainWindow::competition()->addTimeStamp(ts);
				ts->setRunID(myRun->getID());
				myRun->setGoalTimeID(ts->getID());
			}else{
				ts = MainWindow::competition()->getTimeStamp(myRun->getGoalTimeID());
			}
		}

		// if new time != old time
		// compare strings, because of sub-0.01s differences, which should be ignored
		if(MainWindow::convertTimeToString(ts->getTime()) != MainWindow::convertTimeToString(t)){
			ts->setTime(t);
			ts->setSource(TimeStamp::E);
			emit timeEdited(myRun);
		}
	}
	hide();
}