#include <climits>
#include <iostream>
using namespace std;
class Date
{
//friend ostream& operator<<(ostream& out, const Date& d);
friend istream& operator>>(istream& in, Date& d);
public:
Date(int year, int month, int day);
bool operator==(const Date& d);
bool operator>=(const Date& d);
bool operator<=(const Date& d);
bool operator>(const Date& d);
bool operator<(const Date& d);
bool operator!=(const Date& d);
Date& operator+=(int day);
Date& operator-=(int day);
Date operator+(int day);
Date operator-(int day);
Date& operator++();//前置
Date operator++(int);//后置
Date& operator--();//前置
Date operator--(int);//后置
int operator-(const Date&d);
inline int GetDay(int year,int month)//获取天数,内联函数
{
static int GetMonthDay[13] = { -1,31,28,31,30,31,30,31,31,30,31,30,31 };
if (month == 2 && ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0))
{
return 29;
}
else
{
return GetMonthDay[month];
}
}
//private:
int _year;
int _month;
int _day;
};
//ostream& operator<<(ostream& out, const Date& d);
istream& operator>>(istream& in, Date& d);
Date::Date(int year , int month , int day)
{
_year = year;
_month = month;
_day = day;
}
bool Date::operator==(const Date& d)
{
return _year == d._month
&& _month == d._month
&& _day == d._day;
}
bool Date::operator>(const Date& d)
{
if (_year > d._year)
{
return true;
}
else if (_year == d._year)
{
if (_month > d._month)
{
return true;
}
else if(_month==d._month)
{
if (_day > d._day)
{
return true;
}
}
}
return false;
}
bool Date::operator<=(const Date& d)
{
return (! (*this > d)) || (*this == d);
}
bool Date::operator>=(const Date& d)
{
return (*this > d) || (*this == d);
}
bool Date::operator<(const Date& d)
{
return !(*this >= d);
}
bool Date::operator!=(const Date& d)
{
return !(*this == d);
}
Date& Date::operator+=(int day)
{
if (day < 0)
{
return *this -= -day;
}
_day += day;
while (_day > GetDay(_year,_month))
{
_day -= GetDay(_year,_month);
++_month;
if (_month == 13)
{
++_year;
_month = 1;
}
}
return *this;
}
Date& Date::operator-=(int day)
{
if (day < 0)
{
return *this += -day;
}
_day -= day;
while (_day <= 0)
{
--_month;
if (_month == 0)
{
-- _year;
_month = 12;
}
_day += GetDay(_year, _month);
}
if (_day > GetDay(_year, _month))
{
_day = GetDay(_year, _month) - _day;
}
return *this;
}
Date Date::operator+(int day)
{
Date tmp = *this;
tmp += day;
return tmp;
}
Date Date::operator-(int day)
{
Date tmp = *this;
tmp -= day;//复用
return tmp;
}
Date& Date::operator++()//前置
{
*this += 1;
return *this;
}
Date Date:: operator++(int)//后置
{
Date tmp(*this);
*this += 1;
return tmp;
}
Date& Date:: operator--()//前置
{
*this -= 1;
return *this;
}
Date Date::operator--(int)//后置
{
Date tmp(*this);
*this -= 1;
return tmp;
}
int Date::operator-(const Date& d)
{
int flag = 1;
Date max = *this;
Date min = d;
if (*this < d)
{
max = d;
min = *this;
}
int day = 0;
while (min < max)
{
++(min);
++day;
}
return day * flag;
}
istream& operator>>(istream& in, Date& d)
{
in >> d._year>>d._month>>d._day;
return in;
}
int main()
{
Date d1(2024, 1, 2);
Date d2(0, 0, 0);
scanf("%4d%2d%2d", &d1._year,&d1._month,&d1._day);
scanf("%4d%2d%2d", &d2._year, &d2._month, &d2._day);
int count = ( d1 - d2);
cout << count<< endl;
return 0;
}