#include "date.h"
#include "utils.h"
#include <iostream>
using std::cout;
using std::endl;
Date::Date()
{
year=1970;
month=1;
day=1;
}
Date::Date(int y,int m,int d)
{
year=y;
month=m;
day=d;
}
int Date::getYear() const
{
return year;
}
int Date::getMonth() const
{
return month;
}
int Date::getDay() const
{
return day;
}
int Date::dayOfYear()
{
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
if( (year % 4 == 0 && year % 100 !=0) || (year % 400 == 0) )
{
a[1]=29;
}
int i,sum=0;
for(i=0;i<month-1;i++)
{
sum=sum+a[i];
}
sum=sum+day;
return sum;
}
void Date::display()
{
cout<<year<<"年"<<month<<"月"<<day<<"日"<<endl;
}