Esempio n. 1
0
void main()
{
	ifstream inStream;
	int cases;

	inStream.open("input.txt");
	if(inStream.fail())
	{
		cerr<<"Input file opening failed.\n";
		exit(1);
	}

	inStream>>cases;

	for(int i=0;i<cases;i++)
	{
		int year, month, day;

		inStream>>year>>month>>day;
		date date1(year, month, day), date2;

		cout<<date1.getyear()<<" ";
		cout<<date1.getmonth()<<" ";
		cout<<date1.getdayofmonth()<<" "<<endl;
		cout<<date1.isleapyear()<<" ";
		cout<<date1.getdayofweek()<<" "<<endl;

		inStream>>year>>month>>day;
		date2.setdayofmonth(day);
		date2.setmonth(month);
		date2.setyear(year);

		cout<<date2.getyear()<<" ";
		cout<<date2.getmonth()<<" ";
		cout<<date2.getdayofmonth()<<" "<<endl;
		cout<<date2.isleapyear()<<" ";
		cout<<date2.getdayofweek()<<" "<<endl;

		inStream>>year>>month>>day;
		date2.setdate(year, month, day);

		cout<<date2.getyear()<<" ";
		cout<<date2.getmonth()<<" ";
		cout<<date2.getdayofmonth()<<" "<<endl;
		cout<<date2.isleapyear()<<" ";
		cout<<date2.getdayofweek()<<" "<<endl;
	}
	inStream.close();
}
void
RelativeDateUnitTest::test_lifecycle_invalid()
{

	//test: RelativeDateUnit::RelativeDateUnit(const String& stringRep) - invalid date string;
	try{
		RelativeDateUnit date1("1Z");
	}
	catch (BaseException& ex)
	{
		std::cout << "Expected exception (Invalid date string): " << ex.what() << std::endl;
	}
	 

}
void
RelativeDateUnitTest::test_accessor()
{
	RelativeDateUnit date1("12Y");
	//test: RelativeDateUnit::virtual void setQuantity(Integer quantity);
	//test: RelativeDateUnit Date::virtual Integer getQuantity() const;
	date1.setQuantity(30);
	CPPUNIT_ASSERT_EQUAL(30, date1.getQuantity());

	//test: RelativeDateUnit::virtual void setUnit(RelativeDateUnit::eRelativeDateUnit);
	//test: RelativeDateUnit::virtual RelativeDateUnit::eRelativeDateUnit getUnit() const;
	date1.setUnit(RelativeDateUnitType::Day);
	CPPUNIT_ASSERT_EQUAL(RelativeDateUnitType::Day, date1.getUnit());

	
	
}
Esempio n. 4
0
//查询两个日期间的收入
QVector<QString> WQuery::queryBetweenTwoDatesIncome(QDate dateFrom, QDate dateTo){
    //将时间转化为字符串
    QDateTime date1(dateFrom),date2(dateTo.addDays(1));
    QString date3 = date1.toString("yyyy-MM-dd hh:mm:ss");
    QString date4 = date2.toString("yyyy-MM-dd hh:mm:ss");

    //从数据库获取信息
    DBTransactionRecordManip transferManip;
    QString selectInfo;
    selectInfo = QString("SELECT sum,time,type FROM transactionRecord WHERE accountKey2 = %1 AND time > datetime('%2') AND time < datetime('%3')")
            .arg(DBAccountManip::dbSelectAccountKey(number)).arg(date3).arg(date4);
    QVector<QString> infoBetweenTwoDays;
    infoBetweenTwoDays = transferManip.dbSelect(selectInfo,3);
    for(int i = 0;i<infoBetweenTwoDays.size()/3;i++)
        if(infoBetweenTwoDays[3*i + 2] == "transfer to other")
            infoBetweenTwoDays[3*i + 2] = "be transfered into";

    //构造相应的datetime对象
    int rows = infoBetweenTwoDays.size()/3;
    QDateTime times[rows];
    for(int i = 0;i<rows;i++)
        times[i] = QDateTime::fromString(infoBetweenTwoDays[3*i + 1],"yyyy-MM-dd hh:mm:ss");

    //比较,冒泡排序
    for(int i = 0;i<rows -1;i++)
        for(int j = 0;j<rows -1;j++){
            if(times[j]<times[j + 1]){
                QDateTime temp;
                temp = times[j];
                times[j] = times[j + 1];
                times[j + 1] = temp;
                QString temps[3];
                temps[0] = infoBetweenTwoDays[3*j];
                temps[1] = infoBetweenTwoDays[3*j + 1];
                temps[2] = infoBetweenTwoDays[3*j + 2];
                infoBetweenTwoDays[3*j] = infoBetweenTwoDays[3*(j+1)];
                infoBetweenTwoDays[3*j + 1] = infoBetweenTwoDays[3*(j+1) + 1];
                infoBetweenTwoDays[3*j + 2] = infoBetweenTwoDays[3*(j+1) + 2];
                infoBetweenTwoDays[3*(j+1)] = temps[0];
                infoBetweenTwoDays[3*(j+1) + 1] = temps[1];
                infoBetweenTwoDays[3*(j+1) + 2] = temps[2];
            }
        }
    return infoBetweenTwoDays;
}
Esempio n. 5
0
	void date_test_object_t::test<4>()
	{
		LLDate date1(VALID_DATE);
		LLDate date2(date1);
		ensure_equals("LLDate(const LLDate& date) constructor failed", date1.asString(), date2.asString());
	}
Esempio n. 6
0
void DateTimeTextMatchPlugin::doGetPossibleMatches( const QString& text )
{
    //
    // check for years (numbers between 1900 and 2020 for example)
    // check for stuff like "June 22" or even "June 22-26th" (the latter can be used as start and end time already)
    // check for "2 o'clock"
    // check for "14:23"
    // check for 12.6.2009 and 6/12/2009 and 6/12/09 and 6.12.09
    //

    m_years.clear();
    m_dates.clear();
    m_times.clear();
    m_dateRanges.clear();
    m_text = text;

    // we are english-only here!
    QStringList longMonthNames;
    QStringList shortMonthNames;
    for ( int i = 1; i <= 12; ++i ) {
        longMonthNames << m_enLocale.monthName( i, QLocale::LongFormat );
        shortMonthNames << m_enLocale.monthName( i, QLocale::ShortFormat );
    }

    //
    // most of the dates and times can be checked with QRegExp
    //

    // DD.MM.YYYY
    QRegExp date1( "\\b\\d{1,2}\\.\\d{1,2}\\.\\d{4,4}\\b" );

    // DD.MM.YY
    QRegExp date2( "\\b\\d{1,2}\\.\\d{1,2}\\.\\d{2,2}\\b" );

    // MM/DD/YYYY
    QRegExp date3( "\\b\\d{1,2}/\\d{1,2}/\\d{4,4}\\b" );

    // MM/DD/YY
    QRegExp date4( "\\b\\d{1,2}/\\d{1,2}/\\d{2,2}\\b" );

    // January MM [YYYY] (no word boundry at the end for 'st' or 'nd' or 'th') (also excluding ranges)
    QRegExp date5( QString( "\\b(%1)\\s\\d{1,2}(?!(\\d|\\s?-\\s?\\d))(\\s\\d{4,4})?" ).arg( longMonthNames.join( "|" ) ) );

    // January, MM [YYYY] (no word boundry at the end for 'st' or 'nd' or 'th') (also excluding ranges)
    QRegExp date6( QString( "\\b(%1),\\s?\\d{1,2}(?!(\\d|\\s?-\\s?\\d))(\\s\\d{4,4})?" ).arg( longMonthNames.join( "|" ) ) );

    // FIXME: date ranges 1-4

    QRegExp dateRange5( QString( "(\\b(?:%1)\\s\\d{1,2})\\s?-\\s?(\\d{1,2})(\\s\\d{4,4})?" ).arg( longMonthNames.join( "|" ) ) );

    QRegExp dateRange6( QString( "(\\b(?:%1),\\s?\\d{1,2})\\s?-\\s?(\\d{1,2})(\\s\\d{4,4})?" ).arg( longMonthNames.join( "|" ) ) );

    // YYYY (exclude those in full dates matched by the above)
    QRegExp year( "[^\\./]\\d{4,4}\\b" );

    // hh:mm[pm|am]
    QRegExp time1( "\\b\\d{1,2}\\:\\d{2,2}\\s?(pm|am|AM|PM)?\\b" );

    // hh:mm
    QRegExp time2( "\\b\\d{1,2}\\:\\d{2,2}\\b(?!\\s?(pm|am|AM|PM))\\b" );

    // hh o'clock
//    QRegExp time3( "\\b\\d{1,2}\\so'clock\\b" );

    lookForYears( year );

    lookForDates( date1, "d.M.yyyy" );
    lookForDates( date2, "d.M.yy" );
    lookForDates( date3, "M/d/yyyy" );
    lookForDates( date4, "M/d/yy" );
    lookForDates( date5, "MMMM d", true );
    lookForDates( date5, "MMMM d yyyy" );
    lookForDates( date6, "MMMM, d", true );
    lookForDates( date6, "MMMM,d", true );
    lookForDates( date6, "MMMM, d yyyy" );
    lookForDates( date6, "MMMM,d yyyy" );

    lookForDateRanges( dateRange5, "MMMM d", 1, 2, 3, true );
    lookForDateRanges( dateRange5, "MMMM d yyyy", 1, 2, 3, false );
    lookForDateRanges( dateRange6, "MMMM,d", 1, 2, 3, true );
    lookForDateRanges( dateRange6, "MMMM, d", 1, 2, 3, true );
    lookForDateRanges( dateRange6, "MMMM,d yyyy", 1, 2, 3, false );
    lookForDateRanges( dateRange6, "MMMM, d yyyy", 1, 2, 3, false );

    lookForTimes( time1, "h:map" );
    lookForTimes( time1, "h:m ap" );
    lookForTimes( time2, "h:m" );

    // FIXME: do a date and time proximity search to create combined datetime objects

    //
    // Now use the dates and times to create statements
    //
    for ( QHash<int, QPair<QDate, int> >::const_iterator it = m_dates.constBegin();
          it != m_dates.constEnd(); ++it ) {
        // FIXME: this is not great: 1. dtstart has range dateTime, 2. we do not know that it is a start
        //        better use something else or even create Scribo::Literal as alternative to Entity
        Scribo::Statement s( Nepomuk::Vocabulary::PIMO::dtstart(), Nepomuk::Variant( it.value().first ), Soprano::Graph() );
        Scribo::TextOccurrence oc;
        oc.setStartPos( it.key() );
        oc.setLength( it.value().second );
//        oc.setRelevance( 0.9 ); ?????????
        s.addOccurrence( oc );
        addNewMatch( s );
    }

    for ( QHash<int, QPair<QTime, int> >::const_iterator it = m_times.constBegin();
          it != m_times.constEnd(); ++it ) {
        // FIXME: this is not great: 1. dtstart has range dateTime, 2. we do not know that it is a start
        //        better use something else or even create Scribo::Literal as alternative to Entity
        Scribo::Statement s( Nepomuk::Vocabulary::PIMO::dtstart(), Nepomuk::Variant( it.value().first ), Soprano::Graph() );
        Scribo::TextOccurrence oc;
        oc.setStartPos( it.key() );
        oc.setLength( it.value().second );
//        oc.setRelevance( 0.9 ); ?????????
        s.addOccurrence( oc );
        addNewMatch( s );
    }

    for ( QHash<int, QPair<QPair<QDate, QDate>, int> >::const_iterator it = m_dateRanges.constBegin();
          it != m_dateRanges.constEnd(); ++it ) {
        // FIXME: this is not great: 1. dtstart has range dateTime, 2. we do not know that it is a start
        //        better use something else or even create Scribo::Literal as alternative to Entity
        Scribo::Statement s1( Nepomuk::Vocabulary::PIMO::dtstart(), Nepomuk::Variant( it.value().first.first ), Soprano::Graph() );
        Scribo::TextOccurrence oc1;
        oc1.setStartPos( it.key() );
        oc1.setLength( it.value().second );
//        oc.setRelevance( 0.9 ); ?????????
        s1.addOccurrence( oc1 );
        addNewMatch( s1 );

        Scribo::Statement s2( Nepomuk::Vocabulary::PIMO::dtend(), Nepomuk::Variant( it.value().first.second ), Soprano::Graph() );
        Scribo::TextOccurrence oc2;
        oc2.setStartPos( it.key() );
        oc2.setLength( it.value().second );
//        oc.setRelevance( 0.9 ); ?????????
        s2.addOccurrence( oc2 );
        addNewMatch( s2 );
    }

    emitFinished();
}
Esempio n. 7
0
//查询某两个日期之间的交易和付款记录
QVector<QString> WQuery::queryBetweenTwoDates(QDate dateFrom, QDate dateTo){
    //将时间转化为字符串
    QDateTime date1(dateFrom),date2(dateTo.addDays(1));
    QString date3 = date1.toString("yyyy-MM-dd hh:mm:ss");
    QString date4 = date2.toString("yyyy-MM-dd hh:mm:ss");

    //从数据库获取信息
    DBTransactionRecordManip transferManip;
    DBPaymentRecordManip paymentManip;
    QString selectInfo1,selectInfo2,selectInfo3;
    selectInfo1 = QString("SELECT sum,time,type FROM transactionRecord WHERE accountKey1 = %1 AND time > datetime('%2') AND time < datetime('%3')")
            .arg(DBAccountManip::dbSelectAccountKey(number)).arg(date3).arg(date4);
    selectInfo2 = QString("SELECT sum,time,type FROM transactionRecord WHERE accountKey1 != %1 AND accountKey2 = %1 AND time > datetime('%2') AND time < datetime('%3')")
            .arg(DBAccountManip::dbSelectAccountKey(number)).arg(date3).arg(date4);
    selectInfo3 = QString("SELECT sum,time,type FROM paymentRecord WHERE accountKey = %1 AND time > datetime('%2') AND time < datetime('%3')")
            .arg(DBAccountManip::dbSelectAccountKey(number)).arg(date3).arg(date4);
    QVector<QString> transactionRecord1, transactionRecord2,paymentRecord;
    transactionRecord1 = transferManip.dbSelect(selectInfo1,3);
    transactionRecord2 = transferManip.dbSelect(selectInfo2,3);
    paymentRecord = paymentManip.dbSelect(selectInfo3,3);

    //构造返回的QVector
    QVector<QString> infoBetweenTwoDays;
    int size1 = transactionRecord1.size()/3;
    int size2 = transactionRecord2.size()/3;
    int size3 = paymentRecord.size()/3;
    for(int i = 0;i<size1*3;i++)
        infoBetweenTwoDays.push_back(transactionRecord1[i]);
    for(int i = 0;i<size2;i++){
        infoBetweenTwoDays.push_back(transactionRecord1[3*i]);
        infoBetweenTwoDays.push_back(transactionRecord1[3*i + 1]);
        infoBetweenTwoDays.push_back("be transfered into");
    }
    for(int i = 0;i<size3*3;i++)
        infoBetweenTwoDays.push_back(paymentRecord[i]);

    //构造相应的datetime对象
    int rows = size1 + size2 + size3;
    QDateTime times[rows];
    for(int i = 0;i<rows;i++)
        times[i] = QDateTime::fromString(infoBetweenTwoDays[3*i + 1],"yyyy-MM-dd hh:mm:ss");

    //比较,冒泡排序
    for(int i = 0;i<rows -1;i++)
        for(int j = 0;j<rows -1;j++){
            if(times[j]<times[j + 1]){
                QDateTime temp;
                temp = times[j];
                times[j] = times[j + 1];
                times[j + 1] = temp;
                QString temps[3];
                temps[0] = infoBetweenTwoDays[3*j];
                temps[1] = infoBetweenTwoDays[3*j + 1];
                temps[2] = infoBetweenTwoDays[3*j + 2];
                infoBetweenTwoDays[3*j] = infoBetweenTwoDays[3*(j+1)];
                infoBetweenTwoDays[3*j + 1] = infoBetweenTwoDays[3*(j+1) + 1];
                infoBetweenTwoDays[3*j + 2] = infoBetweenTwoDays[3*(j+1) + 2];
                infoBetweenTwoDays[3*(j+1)] = temps[0];
                infoBetweenTwoDays[3*(j+1) + 1] = temps[1];
                infoBetweenTwoDays[3*(j+1) + 2] = temps[2];
            }
        }
    return infoBetweenTwoDays;
}
Esempio n. 8
0
void test()
{
      cout << " zDate Class Demo \n\n";

      // default constructor, Jan 1 0000
      zDate a;
      cout << a << endl;
      // Various versions of the constructors
      zDate x(zDate::oct,20,1962);
      cout << x << endl;
      // constructor with a julian
      zDate z( 2450000L );
      cout << z << endl;
      // make a date with system date (tests copy constructor)
      zDate s(zDate::Today());
      cout << s << endl;
      // init with the day of year
      zDate y(33, 1996);
      cout << y << endl;
      // init from current system time
      time_t secs_now = time(NULL);
      zDate n(localtime(&secs_now));
      cout << n << endl;

      // using date addition and subtraction
      zDate adder = x + 10;
      cout << adder << endl;
      adder = adder - 25;
      cout << adder << endl;

      //using subtraction of two date objects
      zDate a1(zDate::Today());
      zDate a2 = a1 + 14;
      cout << (a1 - a2) << endl;
      cout << (a2 += 10) << endl;

      a1++;
      cout << "Tommorrow= " << a1 << endl;

      a1 = zDate(zDate::jul, 14, 1991);
      cout << "a1 (7-14-91) < a2 (" << a2
             << ")? ==> " << ((a1 < a2) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) > a2 ("<< a2
             << ")? ==> " << ((a1 > a2) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) < 8-01-91 ? ==> "
             << ((a1 < zDate(zDate::aug, 1, 1991)) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) > 8-01-91 ? ==> "
             << ((a1 > zDate(zDate::aug, 1, 1991)) ? "TRUE" : "FALSE") << endl;
      cout << "a1 (7-14-91) == 7-14-91 ? ==> "
             << ((a1==zDate(zDate::jul, 14, 1991)) ? "TRUE" : "FALSE") << endl;
      zDate a3 = a1;

      cout << "a1 (" << a1 << ") == a3 (" << a3
             << ") ? ==> " << ((a1==a3) ? "TRUE" : "FALSE") << endl;
      zDate a4 = a1;
      ++a4;
      cout << "a1 ("<< a1 <<") == a4 (" << a4
             << ") ? ==> " << ((a1==a4) ? "TRUE" : "FALSE") << endl;

      zDate a5(zDate::Today());
      cout << "Today is: " << a5 << endl;
      a4 = zDate::Today();
      cout << "Today (a4) is: " << a4 << endl;

      cout << "Today + 4 is: " << (a4 += 4) << endl;
      a4 = zDate::Today();
      cout << "Today - 4 is: " << (a4 -= 4) << endl;
      cout << "=========== Leap Year Test ===========\n";
      a1 = zDate(zDate::jan, 15, 1992);
      cout << a1 << "\t" << ((a1.IsLeapYear()) ? "Leap" : "non-Leap");
      cout << "\t" << "day of year:  " << a1.DayOfYear() << endl;

      a1 = zDate(zDate::feb, 16, 1993);
      cout << a1 << "\t" << ((a1.IsLeapYear()) ? "Leap" : "non-Leap");
      cout << "\t" << "day of year:  " << a1.DayOfYear() << endl;

      zDate v4(zDate::Today());
      cout << "---------- Add Stuff -----------\n";
      cout << "Start => " << v4 << endl;
      cout << "Add  4 Weeks  => " << v4.AddWeeks(4) << endl;
      cout << "Sub 52 Weeks  => " << v4.AddWeeks(-52)  << endl;
      cout << "Add  2 Years  => " << v4.AddYears(2)    << endl;

      cout << flush;

      cout << "---------- Misc Stuff -----------\n";
      cout << "The date aboves' day of the month is => " << v4.Day() << endl;
      cout << "There are " << v4.DaysInMonth() << " days in this month.\n";
      cout << "This day happens to be " << v4.DayOfWeek() << " day of week" << endl;
      cout << "on the " << v4.WeekOfYear() << " week of the year," << endl;
      cout << "on the " << v4.WeekOfMonth() << " week of the month, " << endl;
      cout << "which is the "<< (int)v4.Month() << "nth month in the year.\n";
      cout << "The year alone is " << v4.Year() << endl;
      cout << "And this is the " << v4.DayOfYear() << " day of year" << endl;
      cout << "of a year with " << v4.DaysInYear() << " days in it" << endl;
      cout << "which makes exatcly " << v4.WeeksInYear() << " weeks" << endl;

      zDate birthday(zDate::jul, 16, 1973);
      cout << "The age test: i was born on " << birthday
             << " which makes me " << v4.Age(birthday) << " years old" << endl;

      zDate       D2(zDate::jul, 4, 1776);
      int         I1 = 4;

      cout << "Before: I1 = " << I1 << ",  D2 = " << D2 << endl;
      cout << "---------- Postfix '++' test -----------\n";
      cout << "Test : I1++ = " << I1++ << ",  D2++ = " << D2++ << endl;
      cout << "After: I1   = " << I1 << ",  D2   = " << D2 << endl;

      cout << "---------- Prefix '++' test -----------\n";
      cout << "Test : ++I1 = " << ++I1 << ",  ++D2 = " << ++D2 << endl;
      cout << "After:   I1 = " << I1 << ",    D2 = " << D2 << endl;

      cout << "---------- Postfix '--' test -----------\n";
      cout << "Test : I1-- = " << I1-- << ",  D2-- = " << D2-- << endl;
      cout << "After: I1   = " << I1 << ",  D2   = " << D2 << endl;

      cout << "---------- Prefix '--' test -----------\n";
      cout << "Test : --I1 = " << --I1 << ",  --D2 = " << --D2 << endl;
      cout << "After:   I1 = " << I1 << ",    D2 = " << D2 << endl;

      cout << "Last day of this year is dayno "
             << zDate(zDate::dec, 31, 1996).DayOfYear() << endl;
      cout << "Last day of prev year is dayno "
             << zDate(zDate::dec, 31, 1995).DayOfYear() << endl;

      cout << "Today the moon is " << zDate::Today().MoonPhase() << endl;

      zDate today = zDate::Today();

      cout << "DST for " << today.Year() << " starts on " << today.BeginDST()
             << " and ends on " << today.EndDST() << endl;
      cout << "Today, " << today << ", DST is "
             << (today.IsDST() ? "" : "not") << "in effect" << endl;

      zDate date1(zDate::aug, 31, 1996);
      cout << "Adding 6 months to " << date1 << " results in "
             << date1.AddMonths(6) << endl;

      zDate date2(zDate::mar, 31, 1996);
      cout << "Subtracting 1 month from " << date2 << " results in "
             << date2.AddMonths(-1) << endl;

      zDate date3(zDate::jul, 4, 1776);
      cout << "Adding 2400 months to " << date3 << " results in "
             << date3.AddMonths(2400) << endl;

      cout << "Today's day number is " << zDate::Today().DayNumber() << endl;

      zDate date4(zDate::feb, 29, 1996);
      cout << date4 << " subtract two years = " << date4.AddYears(-2) << endl;

      cout << "In 1996, DST began on " << zDate::BeginDST(1996) << endl;

      zDate date5(zDate::sep, 26, 1996);
      cout << "Moon phase on " << date5 << " was " << date5.MoonPhase() << endl;

      zDate date6(zDate::oct, 3, 1996);
      cout << date6 << " + 55 days is " << (date6 + 55) << endl;

      zDate date7(zDate::oct, 4, 1996);
      cout << date7 << " + 217 days is ";
      date7 += 217;
      cout << date7 << endl;
      date7 = zDate(zDate::oct, 4, 1996);
      cout << "Same date - (-217) days is ";
      date7 -= -217;
      cout << date7 << endl;

      cout << "For 1996, Easter is on " << zDate::Easter(1996) << endl;
}
Esempio n. 9
0
int main(int argc, const char *argv[]) {
    {
        // 日期创建
        boost::gregorian::date date1(boost::gregorian::from_string("2016-2-9"));
        boost::gregorian::date date2(boost::gregorian::from_simple_string("2016-2-9"));
        boost::gregorian::date date3(boost::gregorian::from_simple_string("2016-Feb-9"));
        boost::gregorian::date date4(boost::gregorian::from_undelimited_string("20160209"));
        boost::gregorian::date date5(boost::gregorian::date_from_iso_string("20160209"));
        boost::gregorian::date date6(2016, 2, 9);
        boost::gregorian::date date7(2016, boost::gregorian::Feb, 9);
        std::cout << "date1: " << date1 << std::endl;
        std::cout << "date2: " << date2 << std::endl;
        std::cout << "date3: " << date3 << std::endl;
        std::cout << "date4: " << date4 << std::endl;
        std::cout << "date5: " << date5 << std::endl;
        std::cout << "date6: " << date6 << std::endl;
        std::cout << "date7: " << date7 << std::endl;
    } {
        // 当前日期
        boost::gregorian::date today(boost::gregorian::day_clock::local_day());
        std::cout << "today: " << today << std::endl;
    } {
        // 日期运算
        boost::gregorian::date today(boost::gregorian::day_clock::local_day());
        boost::gregorian::date date1 = today + boost::gregorian::days(100);
        std::cout << "today: " << date1 << std::endl;
        std::cout << "duration: " << (date1 - today).days() << std::endl;
        std::cout << "date1 > today: " << (date1 > today) << std::endl;
    } {
        // 日期字符串
        boost::gregorian::date today(boost::gregorian::day_clock::local_day());
        std::cout << "today: " << boost::gregorian::to_iso_string(today) << std::endl;
        std::cout << "today: " << boost::gregorian::to_iso_extended_string(today) << std::endl;
    } {
        // 日期属性
        boost::gregorian::date today(boost::gregorian::day_clock::local_day());
        std::cout << "year: " << today.year() << std::endl;
        std::cout << "month: " << today.month() << std::endl;               // Jan, Feb
        std::cout << "month: " << today.month().as_number() << std::endl;   // month of year 1-12
        std::cout << "day: " << today.day() << std::endl;                   // day of month 1-31
        std::cout << "day of year: " << today.day_of_year() << std::endl;   // day of year  1-366
        std::cout << "day of week: " << today.day_of_week() << std::endl;   // Mon, Tue
        std::cout << "day of week: " << today.day_of_week().as_number() << std::endl;   // 1-7
        std::cout << "week number: " << today.week_number() << std::endl;   // 1-53
        std::cout << "day number: " << today.day_number() << std::endl;     // total day
        std::cout << "end of month: " << today.end_of_month() << std::endl; // 2016-Feb-29
    } {
        // 日期循环
        boost::gregorian::date t1(boost::gregorian::from_simple_string("2016-2-9"));
        boost::gregorian::date t2(boost::gregorian::from_simple_string("2016-3-9"));
        for (boost::gregorian::date d = t1; d != t2; d += boost::gregorian::days(1)) {
            std::cout << d << std::endl;
        }
    } {
        // ptime
        boost::posix_time::ptime t1(boost::gregorian::date(2016, 2, 9), boost::posix_time::hours(18));
        boost::posix_time::ptime t2(boost::gregorian::date(2016, 2, 9), boost::posix_time::time_duration(19, 1, 1, 0));
        auto d = t2 - t1;
        std::cout << d.total_seconds() << std::endl;
    }
    
    return 0;
}