boost學習筆記(七)---date_time庫

 date_time庫的日期基於格里高利曆,支持從1400-01-01到9999-12-31之間的日期計算spa

#define BOOST_DATE_TIME_SOURCE
#include <boost\date_time\gregorian\gregorian.hpp>
#include <boost\assert.hpp>
using namespace boost::gregorian;

int main()
{
    date d1;       //一個無效的日期
    boost::gregorian::date d2(2010,1,1);//使用數字構造日期
    date d3(2000,Jan,1);//也可使用英文指定月份
    date d4(d2);//date支持拷貝構造

    assert(d1==date(not_a_date_time));
    assert(d2==d4);
    assert(d3<d4);
}
相關文章
相關標籤/搜索