日期相减
int Date::Num( Date & d)
{
Date res = *this;
uint tmp;
uint src, m1 = 0, m2 = 0, n1 = 0, n2 = 0;
if (res > (d))
{
if (res.m_year == d.m_year)
{
if (res.m_month == d.m_month)
{
return (res.m_day - d.m_day);
}
else
{
while (d.m_month < res.m_month)
{
tmp = getMonthDay(d.m_year, d.m_month);
m1 += tmp;
d.m_month++;
}
return m1 + (unsigned int)(res.m_day - d.m_day);
}
}
else
{
src = getLeapNum(d.m_year, res.m_year);//src里面存放的是d到res之间的闰年的个数
n1 = (res.m_year - d.m_year) * 365 + src;//这时的n存放的是将相差的年数转换为天数,然后剩下的部分就转换成了上面的那个情况
d.m_year = res.m_year;
while (d.m_month < res.m_month)
{
tmp = getMonthDay(d.m_year, d.m_month);
m1 += tmp;
d.m_month++;
}
return n1 + m1 + (unsigned int)(res.m_day - d.m_day);
}
}
else if (res == (d))
{