C++ 获取所有星期日的日期
timer tm;
date dtStartDate = from_undelimited_string("20080116");
date dtEndDate = from_undelimited_string("20130120");
date tem ;
int count = 0;
int gap = 0;
if (dtStartDate > dtEndDate)
{
return ;
}
if (dtStartDate.day_of_week() == 0)
{
tem = dtStartDate;
}
else
{
gap = dtStartDate.day_of_week();
tem = dtStartDate - days(gap);
}
for (; tem <= dtEndDate ; tem += days(7) )
{
++count;
//cout << to_iso_string( tem) << " 星期" << tem.day_of_week() << endl;
}
cout << "总共" << count << "个星期" << endl;
double duration = tm.elapsed();
cout << "总共耗时:" << duration << endl;