利用boost库做万年历,怎么往里面加农历 求指点
/ wannianli.cpp : 定义控制台应用程序的入口点。//
#include "stdafx.h"
#include <iostream>
#include <cmath>
#include <boost/date_time/gregorian/gregorian.hpp>
#include <conio.h>
#include <string>
using std::string;
using namespace std;
using namespace boost::gregorian;
using namespace std;
#define LEFT 75
#define UP 72
#define RIGHT 77
#define DOWN 80
void printrl(date first)
{
vector<string> nm;
nm.push_back("鼠");
nm.push_back("牛");
nm.push_back("虎");
nm.push_back("兔");
nm.push_back("龙");
nm.push_back("蛇");
nm.push_back("马");
nm.push_back("羊");
nm.push_back("猴");
nm.push_back("鸡");
nm.push_back("狗");
nm.push_back("猪");
//从鼠年开始,比较好算
int sxn = 4;
date firstday(first);
if(firstday.year()>=2008)
{
sxn = firstday.year()-2008;
sxn = sxn%12;
}
else
{
sxn = 2008-firstday.year();
sxn = (12-sxn%12)%12;
}
cout<<"sxn="<<sxn<<endl;
date lastdayofmonth = firstday.end_of_month();
cout<<firstday.year()<<" "<<nm[sxn]<<"年"<<(int)firstday.month()<<"月"<<endl;
cout<<"星期一 星期二 星期三 星期四 星期五 星期六 星期日"<<endl;
day_iterator di(firstday);
int wd = firstday.day_of_week();
if(wd == 0)wd=7;
for(int i=1;i<wd;i++)
{
cout<<setw(7)<<"";
}
for(;*di<=lastdayofmonth;++di)
{
cout<<left<<setw(7)<<(*di).day();
if((*di).day_of_week() == 0)
cout<<endl;
}
}
int main()
{
cout << "Boost库的日历显示" << endl;
date today = day_clock::local_day();
date lastdayofmonth = today.end_of_month();
date firstday(today.year(),today.month(),1);
//date firstday(2012,8,1);
printrl(firstday);
int i=0;
char c;
int a;
while(c=getch()!='q')
{
//cin>>c;
c=getch();
int a = c;
if(a==75)
{
system("cls");
printrl(firstday+months(++i));
}
else if(a == RIGHT)
{
system("cls");
printrl(firstday+months(--i));
}
}
return 0;
}