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


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

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


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

示例1: roundtrip

void tst_QDate::roundtrip() const
{
    // Test round trip, this exercises setDate(), isValid(), isLeapYear(),
    // year(), month(), day(), julianDayFromDate(), and getDateFromJulianDay()
    // to ensure they are internally consistent (but doesn't guarantee correct)

    // Test Julian round trip in both BC and AD
    QDate testDate;
    QDate loopDate = QDate::fromJulianDay(1684899); //  1 Jan 100 BC
    while ( loopDate.toJulianDay() <= 1757948 ) {   // 31 Dec 100 AD
        testDate.setDate( loopDate.year(), loopDate.month(), loopDate.day() );
        QCOMPARE( loopDate.toJulianDay(), testDate.toJulianDay() );
        loopDate = loopDate.addDays(1);
    }

    // Test Julian and Gregorian round trip during changeover period
    loopDate = QDate::fromJulianDay(2298153);     //  1 Jan 1580 AD
    while ( loopDate.toJulianDay() <= 2300334 ) { // 31 Dec 1585 AD
        testDate.setDate( loopDate.year(), loopDate.month(), loopDate.day() );
        QCOMPARE( loopDate.toJulianDay(), testDate.toJulianDay() );
        loopDate = loopDate.addDays(1);
    }

    // Test Gregorian round trip during current useful period
    loopDate = QDate::fromJulianDay(2378497);     //  1 Jan 1900 AD
    while ( loopDate.toJulianDay() <= 2488433 ) { // 31 Dec 2100 AD
        testDate.setDate( loopDate.year(), loopDate.month(), loopDate.day() );
        QCOMPARE( loopDate.toJulianDay(), testDate.toJulianDay() );
        loopDate = loopDate.addDays(1);
    }
}
开发者ID:maxxant,项目名称:qt,代码行数:31,代码来源:tst_qdate.cpp

示例2: maxDate

QDate GeldRechen::maxDate(QDate a,QDate b) {
    //check for null date

    if (a.toJulianDay()> b.toJulianDay()) {

        return a;
    }
    else {

        return b;
    }


}
开发者ID:MrRisoni,项目名称:Gauss,代码行数:14,代码来源:geldrechen.cpp

示例3: dayOfYear

int KCalendarSystem::dayOfYear( const QDate &date ) const
{
    //Take the jd of the given date, and subtract the jd of the first day of that year

    if ( isValid( date ) ) {
        QDate firstDayOfYear;

        if ( setDate( firstDayOfYear, year( date ), 1, 1 ) ) {
            return ( date.toJulianDay() - firstDayOfYear.toJulianDay() + 1 );
        }
    }

    return -1;
}
开发者ID:basilk87,项目名称:smc,代码行数:14,代码来源:kcalendarsystem.cpp

示例4: setDate

void KStarsDateTime::setDate( const QDate &_d ) {
    //Save the JD fraction
    long double jdFrac = djd() - (long double)( date().toJulianDay() );

    //set the integer portion of the JD and add back the JD fraction:
    setDJD( (long double)_d.toJulianDay() + jdFrac );
}
开发者ID:KDE,项目名称:kstars,代码行数:7,代码来源:kstarsdatetime.cpp

示例5: QDate

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

    QDate monthDayCounter = QDate::fromJulianDay(minimumDate_);
    int dayOfMonth = QDate::fromJulianDay(date_).day();

    forever
    {
        QDate monthDayComputation = monthDayCounter;
        if (monthDayComputation.day() > dayOfMonth)
            monthDayComputation = monthDayComputation.addMonths(1);

        if (dayOfMonth > monthDayComputation.daysInMonth())
        {
            monthDayComputation = monthDayComputation.addMonths(1);
            monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), 1);
        }
        else
            monthDayComputation = QDate(monthDayComputation.year(), monthDayComputation.month(), dayOfMonth);

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

        tradeDates.append(date_);
        monthDayCounter = monthDayCounter.addMonths(1);
    }

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

示例6: addYears

QDate KCalendarSystem::addYears( const QDate &date, int numYears ) const
{
    if ( isValid( date ) ) {

        int originalYear, originalMonth, originalDay;
        int newYear, newMonth, newDay;
        QDate firstOfNewMonth, newDate;

        julianDayToDate( date.toJulianDay(), originalYear, originalMonth, originalDay );

        newYear = originalYear + numYears;
        newMonth = originalMonth;

        //Adjust day number if new month has fewer days than old month
        if ( setDate( firstOfNewMonth, newYear, newMonth, 1 ) ) {
            int daysInNewMonth = daysInMonth( firstOfNewMonth );
            newDay = ( daysInNewMonth < originalDay ) ? daysInNewMonth : originalDay;

            if ( setDate( newDate, newYear, newMonth, newDay ) ) {
                return newDate;
            }
        }

    }

    //Is QDate's way of saying is invalid
    return QDate::fromJulianDay( 0 );
}
开发者ID:basilk87,项目名称:smc,代码行数:28,代码来源:kcalendarsystem.cpp

示例7: addLicenseToPerson

bool DbManager::addLicenseToPerson(const int id_person, const int id_license, const QDate& date_of_issue) const
{
    if(id_person > 0 && id_license > 0) {
        QSqlQuery query_select;
        QString query_select_string = "SELECT id FROM people_license WHERE id_person = :id_person AND id_license = :id_license";
        query_select.prepare(query_select_string);
        query_select.bindValue(":id_person", id_person);
        query_select.bindValue(":id_license", id_license);
        if(query_select.exec()) {
            if(query_select.isActive()) {
                if(!query_select.first()) {
                    QSqlQuery query;
                    QString query_string =     "INSERT INTO people_license (id_person, id_license, date_of_issue, is_valid, last_notification)"
                                               "VALUES (:id_person, :id_license, :date, 'true', '-1')";
                    query.prepare(query_string);
                    query.bindValue(":id_person", id_person);
                    query.bindValue(":id_license", id_license);
                    if(date_of_issue != QDate(0, 0, 0)) {
                        query.bindValue(":date", date_of_issue.toJulianDay());
                    } else {
                        query.bindValue(":date", 0);
                    }
                    if(query.exec()) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
开发者ID:sgranfius,项目名称:sns,代码行数:31,代码来源:dbmanager.cpp

示例8: ToBoostChrono

	inline boost::chrono::system_clock::time_point ToBoostChrono(QDate date)
	{
		/// https://en.wikipedia.org/wiki/Julian_day
		/// (JD − 2440587.5) × 86400
		auto unix_time = (date.toJulianDay() - QDATE_JULIAN_DAY_FOR_UNIX_EPOCH) * 24 * 60 * 60;
		return boost::chrono::system_clock::from_time_t(unix_time);
	}
开发者ID:dmlys,项目名称:QtTools,代码行数:7,代码来源:DateUtils.hpp

示例9: 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

示例10: QDateTime

KStarsDateTime::KStarsDateTime( const QDate &_d, const QTime &_t ) :
    //QDateTime( _d, _t, QDateTime::Spec::UTC() )
    QDateTime( _d, _t, Qt::UTC )
{
    //don't call setDJD() because we don't need to compute the time; just set DJD directly
    long double jdFrac = ( _t.hour()-12 + ( _t.minute() + ( _t.second() + _t.msec()/1000.)/60.)/60.)/24.;
    DJD = (long double)( _d.toJulianDay() ) + jdFrac;
}
开发者ID:KDE,项目名称:kstars,代码行数:8,代码来源:kstarsdatetime.cpp

示例11: unsetCustomDatePainting

void DDateTable::unsetCustomDatePainting(const QDate& date)
{
    d->customPaintingModes.remove(date.toJulianDay());

    if (d->customPaintingModes.isEmpty())
    {
        d->useCustomColors = false;
    }
    update();
}
开发者ID:KDE,项目名称:digikam,代码行数:10,代码来源:ddatetable.cpp

示例12: minDate

QDate GeldRechen::minDate(QDate a,QDate b) {


    //qDebug () << "date compar " << a.toString() << " with " << b.toString();
    if ((a.month()==0) && (a.year()==0) && (a.day()==0)) {
        return b;
    }
    else {



        if (a.toJulianDay()> b.toJulianDay()) {
            return b;
        }
        else {
            return a;
        }
    }
}
开发者ID:MrRisoni,项目名称:Gauss,代码行数:19,代码来源:geldrechen.cpp

示例13: dateToJulianDay

// Fake version using QDate, each Calendar System MUST implement the correct version for themselves
// The implementation MUST NOT do validity checking on date ranges, all calls to this function MUST
// instead be wrapped in validity checks, as sometimes we want this to work outside the public valid
// range, i.e. to allow us to internally set dates of 1/1/10000 which are not publically valid but
// are required for internal maths
bool KCalendarSystem::dateToJulianDay( int year, int month, int day, int &jd ) const
{
    QDate date;

    if ( date.setDate( year, month, day ) ) {
        jd = date.toJulianDay();
        return true;
    }

    return false;
}
开发者ID:basilk87,项目名称:smc,代码行数:16,代码来源:kcalendarsystem.cpp

示例14: year

int KCalendarSystem::year( const QDate &date ) const
{
    if ( isValid( date ) ) {
        int year, month, day;

        julianDayToDate( date.toJulianDay(), year, month, day );

        return year;
    }

    return 0;  // How do you denote invalid year when we support -ve years?
}
开发者ID:basilk87,项目名称:smc,代码行数:12,代码来源:kcalendarsystem.cpp

示例15: day

int KCalendarSystem::day( const QDate &date ) const
{
    if ( isValid( date ) ) {
        int year, month, day;

        julianDayToDate( date.toJulianDay(), year, month, day );

        return day;
    }

    return 0;
}
开发者ID:basilk87,项目名称:smc,代码行数:12,代码来源:kcalendarsystem.cpp


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