当前位置: 首页>>代码示例>>C++>>正文


C++ QDate::daysTo方法代码示例

本文整理汇总了C++中QDate::daysTo方法的典型用法代码示例。如果您正苦于以下问题:C++ QDate::daysTo方法的具体用法?C++ QDate::daysTo怎么用?C++ QDate::daysTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QDate的用法示例。


在下文中一共展示了QDate::daysTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: weeks_between_dates

int weeks_between_dates(const QDate &date1, const QDate &date2) {
	const KCalendarSystem *calSys = KGlobal::locale()->calendar();
	return (calSys->dayOfWeek(date1) - calSys->dayOfWeek(date2) + date1.daysTo(date2)) / 7;
}
开发者ID:subosito,项目名称:eqonomize-kde,代码行数:4,代码来源:recurrence.cpp

示例2: expr

QArray<int> OContactAccessBackend_XML::queryByExample ( const OContact &query, int settings,
							const QDateTime& d )
{

	QArray<int> m_currentQuery( m_contactList.count() );
	QListIterator<OContact> it( m_contactList );
	uint arraycounter = 0;

	for( ; it.current(); ++it ){
		/* Search all fields and compare them with query object. Store them into list
		 * if all fields matches.
		 */
		QDate* queryDate = 0l;
		QDate* checkDate = 0l;
		bool allcorrect = true;
		for ( int i = 0; i < Qtopia::Groups; i++ ) {
			// Birthday and anniversary are special nonstring fields and should
			// be handled specially
			switch ( i ){
			case Qtopia::Birthday:
				queryDate = new QDate( query.birthday() );
				checkDate = new QDate( (*it)->birthday() );
			case Qtopia::Anniversary:
				if ( queryDate == 0l ){
					queryDate = new QDate( query.anniversary() );
					checkDate = new QDate( (*it)->anniversary() );
				}

				if ( queryDate->isValid() ){
					if(  checkDate->isValid() ){
						if ( settings & OContactAccess::DateYear ){
							if ( queryDate->year() != checkDate->year() )
								allcorrect = false;
						}
						if ( settings & OContactAccess::DateMonth ){
							if ( queryDate->month() != checkDate->month() )
								allcorrect = false;
						}
						if ( settings & OContactAccess::DateDay ){
							if ( queryDate->day() != checkDate->day() )
								allcorrect = false;
						}
						if ( settings & OContactAccess::DateDiff ) {
							QDate current;
							// If we get an additional date, we
							// will take this date instead of
							// the current one..
							if ( !d.date().isValid() )
								current = QDate::currentDate();
							else
								current = d.date();

							// We have to equalize the year, otherwise
							// the search will fail..
							checkDate->setYMD( current.year(),
									   checkDate->month(),
									   checkDate->day() );
							if ( *checkDate < current )
								checkDate->setYMD( current.year()+1,
										   checkDate->month(),
										   checkDate->day() );

							// Check whether the birthday/anniversary date is between
							// the current/given date and the maximum date
							// ( maximum time range ) !
							qWarning("Checking if %s is between %s and %s ! ",
								 checkDate->toString().latin1(),
								 current.toString().latin1(),
								 queryDate->toString().latin1() );
							if ( current.daysTo( *queryDate ) >= 0 ){
								if ( !( ( *checkDate >= current ) &&
									( *checkDate <= *queryDate ) ) ){
									allcorrect = false;
									qWarning (" Nope!..");
								}
							}
						}
					} else{
						// checkDate is invalid. Therefore this entry is always rejected
						allcorrect = false;
					}
				}

				delete queryDate;
				queryDate = 0l;
				delete checkDate;
				checkDate = 0l;
				break;
			default:
				/* Just compare fields which are not empty in the query object */
				if ( !query.field(i).isEmpty() ){
					switch ( settings & ~( OContactAccess::IgnoreCase
							       | OContactAccess::DateDiff
							       | OContactAccess::DateYear
							       | OContactAccess::DateMonth
							       | OContactAccess::DateDay
							       | OContactAccess::MatchOne
							       ) ){

					case OContactAccess::RegExp:{
//.........这里部分代码省略.........
开发者ID:opieproject,项目名称:opie,代码行数:101,代码来源:ocontactaccessbackend_xml.cpp

示例3: exportcsvHistory

// export history report as csv, all tasks X all dates in one block
QString timetrackerstorage::exportcsvHistory (TaskView      *taskview,
                                            const QDate   &from,
                                            const QDate   &to,
                                            const ReportCriteria &rc)
{
    kDebug(5970) << "Entering function";

    QString delim = rc.delimiter;
    const QString cr = QString::fromLatin1("\n");
    QString err=QString::null;
    QString retval;
    Task* task;
    const int intervalLength = from.daysTo(to)+1;
    QMap< QString, QVector<int> > secsForUid;
    QMap< QString, QString > uidForName;


    // Step 1: Prepare two hashmaps:
    // * "uid -> seconds each day": used while traversing events, as uid is their id
    //                              "seconds each day" are stored in a vector
    // * "name -> uid", ordered by name: used when creating the csv file at the end
    kDebug(5970) << "Taskview Count: " << taskview->count();
    for ( int n=0; n<taskview->count(); n++ )
    {
        task=taskview->itemAt(n);
        kDebug(5970) << "n: " << n << ", Task Name: " << task->name() << ", UID: " << task->uid();
        // uid -> seconds each day
        // * Init each element to zero
        QVector<int> vector(intervalLength, 0);
        secsForUid[task->uid()] = vector;

        // name -> uid
        // * Create task fullname concatenating each parent's name
        QString fullName;
        Task* parentTask;
        parentTask = task;
        fullName += parentTask->name();
        parentTask = parentTask->parent();
        while (parentTask)
        {
            fullName = parentTask->name() + "->" + fullName;
            kDebug(5970) << "Fullname(inside): " << fullName;
            parentTask = parentTask->parent();
            kDebug(5970) << "Parent task: " << parentTask;
        }

        uidForName[fullName] = task->uid();

        kDebug(5970) << "Fullname(end): " << fullName;
    }

    kDebug(5970) << "secsForUid" << secsForUid;
    kDebug(5970) << "uidForName" << uidForName;


    // Step 2: For each date, get the events and calculate the seconds
    // Store the seconds using secsForUid hashmap, so we don't need to translate uids
    // We rely on rawEventsForDate to get the events
    kDebug(5970) << "Let's iterate for each date: ";
    for ( QDate mdate=from; mdate.daysTo(to)>=0; mdate=mdate.addDays(1) )
    {
        kDebug(5970) << mdate.toString();
        KCalCore::Event::List dateEvents = d->mCalendar->rawEventsForDate(mdate);

        for(KCalCore::Event::List::iterator i = dateEvents.begin();i != dateEvents.end(); ++i)
        {
            kDebug(5970) << "Summary: " << (*i)->summary() << ", Related to uid: " << (*i)->relatedTo();
            kDebug(5970) << "Today's seconds: " << todaySeconds(mdate, *i);
            secsForUid[(*i)->relatedTo()][from.daysTo(mdate)] += todaySeconds(mdate, *i);
        }
    }


    // Step 3: For each task, generate the matching row for the CSV file
    // We use the two hashmaps to have direct access using the task name

    // First CSV file line
    // FIXME: localize strings and date formats
    retval.append("\"Task name\"");
    for (int i=0; i<intervalLength; i++)
    {
        retval.append(delim);
        retval.append(from.addDays(i).toString());
    }
    retval.append(cr);


    // Rest of the CSV file
    QMapIterator<QString, QString> nameUid(uidForName);
    double time;
    while (nameUid.hasNext())
    {
        nameUid.next();
        retval.append("\"" + nameUid.key() + "\"");
        kDebug(5970) << nameUid.key() << ": " << nameUid.value() << endl;

        for (int day=0; day<intervalLength; day++)
        {
            kDebug(5970) << "Secs for day " << day << ":" << secsForUid[nameUid.value()][day];
//.........这里部分代码省略.........
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:101,代码来源:timetrackerstorage.cpp

示例4: daysTo

int QtDate::daysTo(const QDate &from, const QDate &to)
{
    return from.daysTo(to);
}
开发者ID:blammit,项目名称:nemo-qml-plugin-calendar,代码行数:4,代码来源:plugin.cpp

示例5: yearsBetween

static int yearsBetween( const QDate & d1, const QDate & d2 ) {
    const int days = d1.daysTo( d2 );
    return qRound( days / DAYS_IN_GREGORIAN_YEAR );
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:4,代码来源:expirydialog.cpp

示例6: loadSchedule

void KMyMoneyBriefSchedule::loadSchedule()
{
    try {
        if (m_index < m_scheduleList.count()) {
            MyMoneySchedule sched = m_scheduleList[m_index];

            m_indexLabel->setText(i18n("%1 of %2", m_index + 1, m_scheduleList.count()));
            m_name->setText(sched.name());
            m_type->setText(KMyMoneyUtils::scheduleTypeToString(sched.type()));
            m_account->setText(sched.account().name());
            QString text;
            MyMoneyMoney amount = sched.transaction().splitByAccount(sched.account().id()).value();
            amount = amount.abs();

            if (sched.willEnd()) {
                int transactions = sched.paymentDates(m_date, sched.endDate()).count() - 1;
                text = i18np("Payment on %2 for %3 with %1 transaction remaining occurring %4.",
                             "Payment on %2 for %3 with %1 transactions remaining occurring %4.",
                             transactions,
                             KGlobal::locale()->formatDate(m_date),
                             amount.formatMoney(sched.account().fraction()),
                             i18n(sched.occurrenceToString().toLatin1()));
            } else {
                text = i18n("Payment on %1 for %2 occurring %3.",
                            KGlobal::locale()->formatDate(m_date),
                            amount.formatMoney(sched.account().fraction()),
                            i18n(sched.occurrenceToString().toLatin1()));
            }

            if (m_date < QDate::currentDate()) {
                if (sched.isOverdue()) {
                    QDate startD = (sched.lastPayment().isValid()) ?
                                   sched.lastPayment() :
                                   sched.startDate();

                    if (m_date.isValid())
                        startD = m_date;

                    int days = startD.daysTo(QDate::currentDate());
                    int transactions = sched.paymentDates(startD, QDate::currentDate()).count();

                    text += "<br><font color=red>";
                    text += i18np("%1 day overdue", "%1 days overdue", days);
                    text += QString(" ");
                    text += i18np("(%1 occurrence.)", "(%1 occurrences.)", transactions);
                    text += "</color>";
                }
            }

            m_details->setText(text);

            m_prevButton->setEnabled(true);
            m_nextButton->setEnabled(true);
            m_skipButton->setEnabled(sched.occurrencePeriod() != MyMoneySchedule::OCCUR_ONCE);

            if (m_index == 0)
                m_prevButton->setEnabled(false);
            if (m_index == (m_scheduleList.count() - 1))
                m_nextButton->setEnabled(false);
        }
    } catch (const MyMoneyException &) {
    }
}
开发者ID:mageddo,项目名称:kmymoney,代码行数:63,代码来源:kmymoneybriefschedule.cpp

示例7: daysTo

int Tools::daysTo(const QDate &from, const QDate &to)
{
    return from.daysTo(to);
}
开发者ID:NyFanomezana,项目名称:freemedforms,代码行数:4,代码来源:tools.cpp

示例8: qDebug

void MainWindow::on_pushButton_2_clicked()
{
    if(ui->B_NIO->text().isEmpty() || ui->S_NO->text().isEmpty()){
        QMessageBox::warning(this,tr("提示"),tr("不能为空"),QMessageBox::Ok);
        ui->B_NIO->clear();
        ui->S_NO->clear();
        return;
    }
    QSqlQuery query;
    QString s_num="";
    QString b_num="";
    QString o_name="";
    QString o_author="";
    QString o_price ="";
    QString s_name="";
    QString b_id="";
    query.prepare("select C_NUM from  COUNT where C_NO = :uid");
    query.bindValue(":uid",ui->S_NO->text());
    query.exec();
    if(query.next()){
        s_num = query.value(0).toString();
    }
    query.prepare("select * from  BOOKS where O_ISBN = :bid");
    query.bindValue(":bid",ui->B_NIO->text());
    query.exec();
    if(query.next()){
        o_name = query.value(1).toString();
        o_author = query.value(2).toString();
        o_price = query.value(4).toString();
        b_num = query.value(5).toString();
    }
    qDebug()<<s_num<<b_num;
    query.prepare("SELECT S_NAME FROM STUDENTS WHERE S_NO = ?");
    query.addBindValue(ui->S_NO->text());
    query.exec();
    if(query.next()){
        s_name = query.value(0).toString();
        qDebug()<<s_name;
    }
    if(s_num.isEmpty()){
        QMessageBox::warning(this,tr("提示"),tr("输入学号错误"),QMessageBox::Ok);
        ui->B_NIO->clear();
        ui->S_NO->clear();
        return;
    }
    if(b_num.isEmpty()){
        QMessageBox::warning(this,tr("提示"),tr("输入ISBN错误"),QMessageBox::Ok);
        ui->B_NIO->clear();
        ui->S_NO->clear();
        return;
    }
    int ss_num=s_num.toInt();
    int bb_num=b_num.toInt();
    ++bb_num;
    ++ss_num;
    qDebug()<<ss_num<<bb_num;
    query.prepare("UPDATE BOOKS SET  O_STORAGE = ? WHERE O_ISBN = ?");
    query.addBindValue(QString::number(bb_num,10));
    query.addBindValue(ui->B_NIO->text());
    query.exec();
    query.prepare("UPDATE COUNT SET  C_NUM = ? WHERE C_NO = ?");
    query.addBindValue(QString::number(ss_num,10));
    query.addBindValue(ui->S_NO->text());
    query.exec();
    QDate date;
    QDate oldDate;
    QString oldDatetem;
    date=date.currentDate();
    QString newdate=date.toString("yyyy.M.d");
    qDebug()<<newdate;
    int countI = ui->tableWidget->rowCount();
    ui->tableWidget->insertRow(countI);
    ui->tableWidget->setItem(countI,0,new QTableWidgetItem(ui->S_NO->text()));
    ui->tableWidget->setItem(countI,1,new QTableWidgetItem(s_name));
    ui->tableWidget->setItem(countI,2,new QTableWidgetItem(ui->B_NIO->text()));
    ui->tableWidget->setItem(countI,3,new QTableWidgetItem(o_name));
    ui->tableWidget->setItem(countI,4,new QTableWidgetItem(o_author));
    ui->tableWidget->setItem(countI,5,new QTableWidgetItem(o_price));
    ui->tableWidget->setItem(countI,6,new QTableWidgetItem(QString(tr("还回"))));
    ui->tableWidget->setItem(countI,8,new QTableWidgetItem(newdate));
    query.prepare("SELECT B_ID,B_TIME FROM BORROW WHERE B_NO = ? AND B_ISBN = ? AND B_ISRENT = 0");
    query.addBindValue(ui->S_NO->text());
    query.addBindValue(ui->B_NIO->text());
    query.exec();
    if(query.first()){
        b_id = query.value(0).toString();
        oldDatetem = query.value(1).toString();
        oldDatetem.replace(QString("-"),QString(""));
        qDebug()<<b_id<<oldDatetem;
    }
    query.prepare("UPDATE BORROW SET B_ISRENT=?,B_RENTTIME=? WHERE B_ID = ?");
    query.addBindValue(1);
    query.addBindValue(newdate);
    query.addBindValue(b_id);
    query.exec();
    oldDate=oldDate.fromString(oldDatetem,"yyyyMMdd");
    qDebug()<<oldDate.toString("yyyy.M.d");
    int timeforBorrow = oldDate.daysTo(date);
    if(timeforBorrow > 30){
        qDebug()<<timeforBorrow;
//.........这里部分代码省略.........
开发者ID:hanliumaozhi,项目名称:DBtest,代码行数:101,代码来源:mainwindow.cpp

示例9: getLabels

bool PSV_Public::getLabels(QVariant &maxValue, QVariant &minValue, QPair<double, double> &range, QList<QPair<QVariant, QString> > &labelList)
{
    if(maxValue.type() != minValue.type())
    {
        return false;
    }
    QVariant::Type type = maxValue.type();
    switch(type)
    {
    case QVariant::Double:
    case QVariant::Int:
    case QVariant::UInt:
    {
        double max = maxValue.toDouble();
        double min = minValue.toDouble();
        int numTick = getNumTicks(max, min);
        if(numTick <= 0)
        {
            return false;
        }
        adjustRange(max, min);
        labelList.clear();
        for(int i = 0; i <= numTick; ++i)
        {
            double value = min + 1.0 * (max - min) * i / numTick;
            QString str = QObject::tr("%1").arg(value);
            labelList.append(QPair<QVariant, QString>(value, str));
        }
        maxValue = max;
        minValue = min;
        range = QPair<double,double>(min,max);
        return true;
    }
        break;
    case QVariant::Date:
    {
        QDate maxDate = maxValue.toDate();
        QDate minDate = minValue.toDate();
        bool isOk = getDateLabels(maxDate, minDate, labelList);
        maxValue = maxDate;
        minValue = minDate;
        range = QPair<double,double>(0.0, 1.0 * minDate.daysTo(maxDate));
        return isOk;
    }
        break;
    case QVariant::Time:
    {
        QTime maxTime = maxValue.toTime();
        QTime minTime = minValue.toTime();
        bool isOk = getTimeLabels(maxTime, minTime, labelList);
        maxValue = maxTime;
        minValue = minTime;
        range = QPair<double,double>(0.0, 86400.0/*1.0 * minTime.secsTo(maxTime)*/);
        return isOk;
    }
        break;
    case QVariant::DateTime:
    {
        QDateTime maxTime = maxValue.toDateTime();
        QDateTime minTime = minValue.toDateTime();
        //        PSV_Public::printMes(maxTime,"1maxTime");
        //        PSV_Public::printMes(minTime,"1minTime");
        bool isOk = getDateTimeLabels(maxTime, minTime, labelList);
        maxValue = maxTime;
        minValue = minTime;
        //        PSV_Public::printMes(maxTime,"2maxTime");
        //        PSV_Public::printMes(minTime,"2minTime");

        range = QPair<double,double>(PSV_BEGIN_DATETIME.secsTo(minValue.toDateTime()),PSV_BEGIN_DATETIME.secsTo(maxValue.toDateTime()));
        return isOk;
    }
        break;
    default:
        break;
    }
    return false;
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:77,代码来源:psv_public.cpp

示例10: ageYears

/** \brief Returns a readable age calculated from the date to now */
int ageYears(const QDate &DOB)
{
    int daysTo = DOB.daysTo(QDate::currentDate());
    double age = daysTo / 365.242199;
    return (int)age;
}
开发者ID:NyFanomezana,项目名称:freemedforms,代码行数:7,代码来源:global.cpp

示例11: getDateLabels

bool PSV_Public::getDateLabels(QDate &maxDate, QDate &minDate, QList<QPair<QVariant, QString> > &labelList)
{
    labelList.clear();
    int maxNum = 31;
    int days = minDate.daysTo(maxDate);
    if(days < 0)
    {
        days = -days;
        qSwap(maxDate, minDate);
    }
    int min_year = minDate.year();
    int min_month = minDate.month();
    int max_year = maxDate.year();
    int max_month = maxDate.month();
    QDate beginDate = QDate(1970, 1, 1);
    QString dateFormat = "";
    if(days <= maxNum)
    {
        if(min_year == max_year)
        {
            dateFormat = QString::fromLocal8Bit("MM月dd日");
        }
        else
        {
            dateFormat = QString::fromLocal8Bit("yyyy年MM月dd日");
        }
        int min_days = beginDate.daysTo(minDate);
        int max_days = beginDate.daysTo(maxDate);
        if(min_days >= max_days)
        {
            max_days = max_days + 1;
            min_days = min_days - 1;
        }
        for(int i = min_days; i <= max_days; ++i)
        {
            QDate tempDate = beginDate.addDays(i);
            labelList.append(QPair<QVariant, QString>(tempDate, tempDate.toString(dateFormat)));
        }
        //        m_min_x = min_days;
        //        m_max_x = max_days;
    }
    else
    {
        int interval = 1;
        dateFormat = QString::fromLocal8Bit("yyyy年MM月");
        int years = max_year - min_year;
        if(years <= 1)
        {
            interval = 1;
        }
        else if( years <= 2)
        {
            interval = 2;
        }
        else if(years <= 3)
        {
            interval = 3;
        }
        else if(years <= 5)
        {
            interval = 6;
        }
        else
        {
            dateFormat = QString::fromLocal8Bit("yyyy年");
            interval = 12;
        }
        int tempMonth = 1;
        int beginMonth =1;
        do
        {
            beginMonth = tempMonth;
            tempMonth += interval;
        }while(tempMonth <= min_month);
        min_month = beginMonth;
        QDate minDate = QDate(min_year, min_month, 1);
        QDate maxDate = QDate(max_year, max_month, 1).addMonths(1).addDays(-1);
        QDate tempDate = minDate;
        labelList.append(QPair<QVariant, QString>(tempDate, tempDate.toString(dateFormat)));
        do
        {
            tempDate = tempDate.addMonths(interval);
            labelList.append(QPair<QVariant, QString>(tempDate, tempDate.toString(dateFormat)));
        }while(maxDate.daysTo(tempDate) <= 0);

    }
    if(labelList.count() >= 2)
    {
        minDate = labelList.at(0).first.toDate();
        maxDate = labelList.at(labelList.count() - 1).first.toDate().addDays(-1);
        return true;
    }
    return false;
}
开发者ID:BIbiLion,项目名称:LSWuqiankun,代码行数:94,代码来源:psv_public.cpp

示例12: alignDate


//.........这里部分代码省略.........
            }
            const int h = qwtAlignValue( hour, stepSize, up );

            dt = QwtDate::floor( dt, QwtDate::Day );
            dt = dt.addSecs( h * 3600 );

            break;
        }
        case QwtDate::Day:
        {
            // What date do we expect f.e. from an alignment of 5 days ??
            // Aligning them to the beginning of the year avoids at least
            // jumping major ticks when panning

            int day = dt.date().dayOfYear();
            if ( up )
            {
                if ( dt.time() > QTime( 0, 0 ) )
                    day++;
            }

            const int d = qwtAlignValue( day, stepSize, up );

            dt = QwtDate::floor( dt, QwtDate::Year );
            dt = dt.addDays( d - 1 );

            break;
        }
        case QwtDate::Week:
        {
            const QDate date = QwtDate::dateOfWeek0(
                dt.date().year(), d_data->week0Type );

            int numWeeks = date.daysTo( dt.date() ) / 7;
            if ( up )
            {
                if ( dt.time() > QTime( 0, 0 ) ||
                    date.daysTo( dt.date() ) % 7 )
                {
                    numWeeks++;
                }
            }

            const int d = qwtAlignValue( numWeeks, stepSize, up ) * 7;

            dt = QwtDate::floor( dt, QwtDate::Day );
            dt.setDate( date );
            dt = dt.addDays( d );

            break;
        }
        case QwtDate::Month:
        {
            int month = dt.date().month();
            if ( up )
            {
                if ( dt.date().day() > 1 ||
                    dt.time() > QTime( 0, 0 ) )
                {
                    month++;
                }
            }

            const int m = qwtAlignValue( month - 1, stepSize, up );

            dt = QwtDate::floor( dt, QwtDate::Year );
开发者ID:OPM,项目名称:ResInsight,代码行数:67,代码来源:qwt_date_scale_engine.cpp

示例13: daysTo

int FLUtil::daysTo( const QDate &d1, const QDate &d2 ) {
  return d1.daysTo( d2 );
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:3,代码来源:FLUtil.cpp

示例14: birthdayIsFuture

bool CPerson::birthdayIsFuture(void) const{
	QDate date = QDate::currentDate();
	QDate birthday = QDate::fromString(geburtstag,"yyyy-MM-dd");
	return (date.daysTo(birthday) > 0);
}
开发者ID:BiCoR,项目名称:x64Client,代码行数:5,代码来源:cPerson.cpp

示例15: calculateDifferenceInDates

QStringList scheduler::calculateDifferenceInDates(QDate start, QDate end, int type)
{
//qDebug() << " \n\n CALCULATING DIFFERENCE IN DATES ";

    QStringList listOfDates;

    int difference  = start.daysTo(end);

    listOfDates.append(start.toString(STANDARD_DATE_FORMAT_2));

    switch(type)
    {
    case 0:
    {
        QDate temp;
        int difference  = start.daysTo(end);

        // Daily Delivery. Make dates for all days except Sat/Sun.

        for( int i = 1; i <= difference; i++ )
        {
            // Add days to start
            temp = start.addDays(i);

            // Ensure non-weekend
            if ( temp.dayOfWeek() != 6 && temp.dayOfWeek() != 7 )
            {
                // Add to list
                listOfDates.append(temp.toString(STANDARD_DATE_FORMAT_2));
            }
        }
        break;
    }
    case 1:
    {
//qDebug() << "\n TYPE = " << type << "\n";

        // Weekly Delivery. Make dates for every 7 days.

        int numberOfDeliveries = difference / 7;

//qDebug() << "\n NUM OF DELIVERIES : " << numberOfDeliveries;

        for( int i = 0, j = 7; i < numberOfDeliveries; i++ )
        {
            QDate temp = start.addDays(j);
            listOfDates.append(temp.toString(STANDARD_DATE_FORMAT_2));
            j+=7;
        }
        break;
    }
    case 2:
    {
//qDebug() << "\n TYPE = " << type << "\n";

        // Monthly. Make dates for every month in series.

        QDate temp;
        bool includedStart = false;
        int daysThisMonth = start.daysInMonth();

        while ( difference != 0 )
        {
            if ( !includedStart )
            {
                temp = start.addDays(daysThisMonth);
                listOfDates.append(temp.toString(STANDARD_DATE_FORMAT_2));
                includedStart = true;
            }
            else
            {
                daysThisMonth = temp.daysInMonth();
                temp = temp.addDays(daysThisMonth);
                listOfDates.append(temp.toString(STANDARD_DATE_FORMAT_2));
            }
            difference -= daysThisMonth;

            if ( difference < 0 )
            {
                // Should never be the case, but if so it prevens infinite loop.
                difference = 0;
            }
        }
        break;
    }
    case 3:
    {
//qDebug() << "\n TYPE = " << type << "\n";

        // Tuesday / Thursday Delivery. Make dates for all in series.

        for( int i = 1; i <= difference; i++ )
        {
            // Add days to start
            QDate temp = start.addDays(i);

            // Ensure is on tuesday or thursday
            if ( temp.dayOfWeek() == 2 || temp.dayOfWeek() == 4 )
            {
                // Add to list
//.........这里部分代码省略.........
开发者ID:LSSUHDTeam,项目名称:ReservationSystem,代码行数:101,代码来源:scheduler.cpp


注:本文中的QDate::daysTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。