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


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

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


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

示例1: onSetPeriodPress

void StatisticWindow::onSetPeriodPress()
{
    switch(ui->comboBoxPeriod->currentIndex()){
        case P_TODAY:{
        ui->dateEditFrom->setDate(QDate::currentDate());
        }
        break;
        case P_WEEK:{
            QDate date = QDate::currentDate();
            ui->dateEditFrom->setDate(date.addDays(-date.dayOfWeek()+1));
        }
        break;
        case P_MONTH:{
            QDate date = QDate::currentDate();
            ui->dateEditFrom->setDate(date.addDays(-date.day()+1));
        }
        break;
        case P_YEAR:{
            QDate date = QDate::currentDate();
            ui->dateEditFrom->setDate(date.addDays(-date.dayOfYear()+1));
        }
        break;
    }
    ui->dateEditTo->setDate(QDate::currentDate());

    onUpdatePress();
}
开发者ID:Allexin,项目名称:TrackYourTime,代码行数:27,代码来源:statisticwindow.cpp

示例2: createDayElements

Element::List Datenums::createDayElements(const QDate &date)
{
    Element::List result;

    int dayOfYear = date.dayOfYear();
    int remainingDays = date.daysInYear() - dayOfYear;

    StoredElement *e;
    switch (mDisplayedInfo) {
    case DayOfYear: // only day of year
        e = new StoredElement(QStringLiteral("main element"), QString::number(dayOfYear));
        break;
    case DaysRemaining: // only days until end of year
        e = new StoredElement(QStringLiteral("main element"), QString::number(remainingDays),
                              i18np("1 day before the end of the year",
                                    "%1 days before the end of the year",
                                    remainingDays));
        break;
    case DayOfYear + DaysRemaining: // both day of year and days till end of year
    default:
        e = new StoredElement(QStringLiteral("main element"), QString::number(dayOfYear),
                              i18nc("dayOfYear / daysTillEndOfYear", "%1 / %2",
                                    dayOfYear, remainingDays),
                              i18np("1 day since the beginning of the year,\n",
                                    "%1 days since the beginning of the year,\n",
                                    dayOfYear) +
                              i18np("1 day until the end of the year",
                                    "%1 days until the end of the year",
                                    remainingDays));
        break;
    }
    result.append(e);

    return result;
}
开发者ID:KDE,项目名称:kdepim-addons,代码行数:35,代码来源:datenums.cpp

示例3: getLastModified

/*
 *  Get the last modification date for a file
 */
QString FileList::getLastModified(QString fullPath)
{
    if (m_lastModifiedMap.contains(fullPath))
        return m_lastModifiedMap.value(fullPath);
    else
    {
        QFileInfo fileInfo(fullPath);

        // Use day/month/year format because it makes more sense and anyone who's willing to tell
        // otherwise is wrong

        // Show only time if the file was modified on the same day
        bool sameDay = false;

        QDate currentDate = QDate::currentDate();

        if (currentDate.dayOfYear() == fileInfo.lastModified().date().dayOfYear() &&
            currentDate.year() == fileInfo.lastModified().date().year())
            sameDay = true;

        QString modifiedString;

        if (sameDay)
            modifiedString = fileInfo.lastModified().toString("hh:mm");
        else
            modifiedString = fileInfo.lastModified().toString("dd/MM/yyyy");

        m_lastModifiedMap.insert(fullPath, modifiedString);

        return modifiedString;
    }
}
开发者ID:Matoking,项目名称:Filetug,代码行数:35,代码来源:filelist.cpp

示例4: weekOfYear

int kMyMoneyCalendar::weekOfYear(const QDate& date)
{
  // Calculate ISO 8601 week number (taken from glibc/Gnumeric)
  int year, week, jan1wday, nextjan1wday;
  QDate jan1date, nextjan1date;

  year = date.year();

  jan1date = QDate(year, 1, 1);
  jan1wday = jan1date.dayOfWeek();

  week = (date.dayOfYear() - 1 + jan1wday - 1) / 7 + ((jan1wday - 1) == 0 ? 1 : 0);

  /* Does date belong to last week of previous year? */
  if ((week == 0) && (jan1wday > 4 /*THURSDAY*/)) {
    QDate tmpdate = QDate(year - 1, 12, 31);
    return weekOfYear(tmpdate);
  }

  if ((jan1wday <= 4 /*THURSDAY*/) && (jan1wday > 1 /*MONDAY*/))
    week++;

  if (week == 53) {
    nextjan1date = QDate(year + 1, 1, 1);
    nextjan1wday = nextjan1date.dayOfWeek();
    if (nextjan1wday <= 4 /*THURSDAY*/)
      week = 1;
  }

  return week;
}
开发者ID:CGenie,项目名称:kmymoney,代码行数:31,代码来源:kmymoneycalendar.cpp

示例5: checkTradeDate

QList<int> tradeDateCalendar::computeFrequencyTradeYearly(int date_, int minimumDate_, int maximumDate_)
{
    QList<int> tradeDates;

    QDate yearDayCounter = QDate::fromJulianDay(minimumDate_);
    int dayOfYear = QDate::fromJulianDay(date_).dayOfYear();

    forever
    {
        QDate yearDayComputation = yearDayCounter;
        int leapDayofYear = dayOfYear + (dayOfYear > 59 /* Feb 28th */ && QDate::isLeapYear(yearDayComputation.year()) ? 1 : 0);

        if (yearDayComputation.dayOfYear() > leapDayofYear)
        {
            yearDayComputation = yearDayComputation.addYears(1);
            leapDayofYear = dayOfYear + (dayOfYear > 59 /* Feb 28th */ && QDate::isLeapYear(yearDayComputation.year()) ? 1 : 0);
        }

        date_ = checkTradeDate(yearDayComputation.toJulianDay(), direction_ascending);
        if (date_ > maximumDate_)
            break;

        tradeDates.append(date_);
        yearDayCounter = yearDayCounter.addYears(1);
    }

    return tradeDates;
}
开发者ID:choff97,项目名称:mypersonalindex,代码行数:28,代码来源:tradeDateCalendar.cpp

示例6: daily

QString SigGenerator::daily() const
{
    if(signatures.count() <= 0)
	return(QString::null);

    QDate date;
    int i = date.dayOfYear() % signatures.count();
    QString text;
    SigListViewItem::nodeToText(signatures.item(i), text);
    return attachStandard(text);
}
开发者ID:iegor,项目名称:kdesktop,代码行数:11,代码来源:siggenerator.cpp

示例7: weekNumber

// The following code is borrowed from QT 3.2 QDate::weekNumber()
// and slightly modified
int kMyMoneyDateTbl::weekNumber(const QDate& date, int *yearNumber) const
{
     if ( !date.isValid() )
        return 0;

    int dow = date.dayOfWeek();
    int doy = date.dayOfYear();
    int currYear = date.year();
    int jan1WeekDay = QDate( currYear, 1, 1 ).dayOfWeek();
    int yearNum;
    int weekNum;

    if ( doy <= (8 - jan1WeekDay) && jan1WeekDay > 4 ) {
        yearNum = currYear - 1;
        weekNum = 52;
        if ( jan1WeekDay == 5 ||
             (jan1WeekDay == 6 && QDate::leapYear(yearNum)) )
            weekNum++;
    } else {
        int totalDays = 365;
        if ( QDate::leapYear(currYear) )
            totalDays++;

        if ( (totalDays - doy < 4 - dow)
             || (jan1WeekDay == 7 && totalDays - doy < 3) ) {
            yearNum = currYear + 1;
            weekNum = 1;
        } else {
            int j = doy + ( 7 - dow ) + ( jan1WeekDay - 1 );
            yearNum = currYear;
            weekNum = j / 7;
            if ( jan1WeekDay > 4 )
                weekNum--;
        }
    }
    if ( yearNumber )
        *yearNumber = yearNum;
    return weekNum;

}
开发者ID:sajidji94,项目名称:kmymoney2,代码行数:42,代码来源:kmymoneydatetbl.cpp

示例8: finishStr

// http://unicode.org/reports/tr35/tr35-6.html#Date_Format_Patterns
static void finishStr(QString &str, const WeekDate &week_date, const QDate &date, const QTime &time, QChar c, int length)
{
    if (length <= 0)
        return;

    switch (c.unicode())
    {
    case L'G':
    {
        bool ad = date.year() > 0;
        if (length < 4)
            str += ad ? "AD" : "BC";
        else if (length == 4)
            str += ad ? "Anno Domini" : "Before Christ";
        else
            str += ad ? "A" : "B";
        break;
    }
    case L'y':
        if (length == 2)
            appendInt(str, date.year() % 100, 2);
        else
            appendInt(str, date.year(), length);
        break;
    case L'Y':
        appendInt(str, week_date.year(), length);
        break;
    case L'u':
    {
        int year = date.year();
        if (year < 0)
            year++;
        appendInt(str, date.year(), length);
        break;
    }
    case L'q':
    case L'Q':
    {
        int q = (date.month() + 2) / 3;
        if (length < 3)
            appendInt(str, q, length);
        else if (length == 3)
        {
            str += 'Q';
            str += QString::number(q);
        }
        else
        {
            switch (q)
            {
            case 1:
                str += qApp->translate("AdiumTimeFormatter", "1st quarter");
                break;
            case 2:
                str += qApp->translate("AdiumTimeFormatter", "2nd quarter");
                break;
            case 3:
                str += qApp->translate("AdiumTimeFormatter", "3rd quarter");
                break;
            case 4:
                str += qApp->translate("AdiumTimeFormatter", "4th quarter");
                break;
            default:
                break;
            }
        }
        break;
    }
    case L'M':
    case L'L':
        if (length < 3)
            appendInt(str, date.month(), length);
        else if (length == 3)
            str += QDate::shortMonthName(date.month());
        else if (length == 4)
            str += QDate::longMonthName(date.month());
        else
            str += QDate::shortMonthName(date.month()).at(0);
        break;
    case L'w':
        TRIM_LENGTH(2);
        appendInt(str, length, week_date.week());
        break;
    case L'W':
        while (length-- > 0)
            str += QString::number((date.day() + 6) / 7);
        break;
    case L'd':
        TRIM_LENGTH(2);
        appendInt(str, date.day(), length);
        break;
    case L'D':
        TRIM_LENGTH(3);
        appendInt(str, date.dayOfYear(), length);
        break;
    case L'F':
        while (length-- > 0)
            str += QString::number(1);
        break;
//.........这里部分代码省略.........
开发者ID:partition,项目名称:kadu,代码行数:101,代码来源:adium-time-formatter.cpp

示例9: convertTimeDate

QString convertTimeDate(const QString &mac_format, const QDateTime &datetime)
{
    QDate date = datetime.date();
    QTime time = datetime.time();
    QString str;
    if (mac_format.contains('%'))
    {
        const QChar *chars = mac_format.constData();
        bool is_percent = false;
        int length = 0;
        bool error = false;
        while ((*chars).unicode() && !error)
        {
            if (is_percent)
            {
                is_percent = false;
                switch ((*chars).unicode())
                {
                case L'%':
                    str += *chars;
                    break;
                case L'a':
                    appendStr(str, QDate::shortDayName(date.dayOfWeek()), length);
                    break;
                case L'A':
                    appendStr(str, QDate::longDayName(date.dayOfWeek()), length);
                    break;
                case L'b':
                    appendStr(str, QDate::shortMonthName(date.day()), length);
                    break;
                case L'B':
                    appendStr(str, QDate::longMonthName(date.day()), length);
                    break;
                case L'c':
                    appendStr(str, QLocale::system().toString(datetime), length);
                    break;
                case L'd':
                    appendInt(str, date.day(), length > 0 ? length : 2);
                    break;
                case L'e':
                    appendInt(str, date.day(), length);
                    break;
                case L'F':
                    appendInt(str, time.msec(), length > 0 ? length : 3);
                    break;
                case L'H':
                    appendInt(str, time.hour(), length > 0 ? length : 2);
                    break;
                case L'I':
                    appendInt(str, time.hour() % 12, length > 0 ? length : 2);
                    break;
                case L'j':
                    appendInt(str, date.dayOfYear(), length > 0 ? length : 3);
                    break;
                case L'm':
                    appendInt(str, date.month(), length > 0 ? length : 2);
                    break;
                case L'M':
                    appendInt(str, time.minute(), length > 0 ? length : 2);
                    break;
                case L'p':
                    appendStr(str, time.hour() < 12 ? "AM" : "PM", length);
                    break;
                case L'S':
                    appendInt(str, time.second(), length > 0 ? length : 2);
                    break;
                case L'w':
                    appendInt(str, date.dayOfWeek(), length);
                    break;
                case L'x':
                    appendStr(str, QLocale::system().toString(date), length);
                    break;
                case L'X':
                    appendStr(str, QLocale::system().toString(time), length);
                    break;
                case L'y':
                    appendInt(str, date.year() % 100, length > 0 ? length : 2);
                    break;
                case L'Y':
                    appendInt(str, date.year(), length > 0 ? length : 4);
                    break;
                case L'Z':
                    // It should be localized, isn't it?..
                    appendStr(str, SystemInfo::instance()->timezone(), length);
                    break;
                case L'z':
                {
                    int offset = SystemInfo::instance()->timezoneOffset();
                    appendInt(str, (offset/60)*100 + offset%60, length > 0 ? length : 4);
                    break;
                }
                default:
                    if ((*chars).isDigit())
                    {
                        is_percent = true;
                        length *= 10;
                        length += (*chars).digitValue();
                    }
                    else
                        error = true;
//.........这里部分代码省略.........
开发者ID:partition,项目名称:kadu,代码行数:101,代码来源:adium-time-formatter.cpp

示例10: loadPlan


//.........这里部分代码省略.........
            updatePos(newTimeStep, aPos, 0);
            timeGrp.appendChild(newTimeStep);
            r = r.addDays(7);
        }
    }
    // Show month
    else if (yLen > 500)
    {
        QDate r;
        if (dateStart.daysInMonth() == 1)
            r.setDate(dateStart.year(), dateStart.month(), dateStart.day());
        else
            r.setDate(dateStart.year(), dateStart.month() + 1, 1);
        while (r < dateEnd)
        {
            QDomElement newTimeStep = mTplTime.cloneNode().toElement();
            if (yLen < 1000)
                updateField(newTimeStep, "{{name}}", r.toString("MMM") );
            else
                updateField(newTimeStep, "{{name}}", r.toString("MMM yy") );
            updateAttr (newTimeStep, "step_block", "width", QString::number(4));

            int offset = dateStart.daysTo(r);
            int aPos = (offset * mPixelPerDay * mZoomLevel);
            updatePos(newTimeStep, aPos, 0);
            timeGrp.appendChild(newTimeStep);
            r = r.addMonths(1);
        }
    }
    // Show Year
    else
    {
        QDate r;
        if (dateStart.dayOfYear() == 1)
            r.setDate(dateStart.year(), dateStart.month(), dateStart.day());
        else
            r.setDate(dateStart.year() + 1, 1, 1);
        while (r < dateEnd)
        {
            QDomElement newTimeStep = mTplTime.cloneNode().toElement();
            updateField(newTimeStep, "{{name}}", QString::number(r.year()) );
            updateAttr (newTimeStep, "step_block", "width", QString::number(4));

            int offset = dateStart.daysTo(r);
            int aPos = (offset * mPixelPerDay * mZoomLevel);
            updatePos(newTimeStep, aPos, 0);
            timeGrp.appendChild(newTimeStep);
            r = r.addYears(1);
        }
    }
    e.appendChild(timeGrp);

    // Insert all the known groups
    for (int i=0; i < plan->countGroups(); i++)
    {
        vlePlanGroup *planGroup = plan->getGroup(i);
        vlePlanActivity *prevActivity = 0;
        int prevLen = 0;
        int prevOffset = 0;

        // Create a new Group
        QDomElement newGrp = mTplHeader.cloneNode().toElement();
        updateField(newGrp, "{{name}}", planGroup->getName());
        updatePos  (newGrp, 0, ((i + 1) * mGroupHeight));
        updateAttr (newGrp, "header_background", "width", QString::number(planWidth));
开发者ID:Hooligan-0,项目名称:vle-timeline-widget,代码行数:66,代码来源:svgview.cpp


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