1 #include "date.h" 2 #include "utils.h" 3 #include4 using std::cout; 5 using std::endl; 6 Date::Date() 7 { 8 year=1970; 9 month=1;10 day=1;11 }12 Date::Date(int y,int m,int d)13 {14 year=y;15 month=m;16 day=d;17 }18 int Date::getYear() const19 {20 return year;21 }22 int Date::getMonth() const23 {24 return month;25 }26 int Date::getDay() const27 {28 return day;29 }30 int Date::dayOfYear()31 {32 int a[12]={ 31,28,31,30,31,30,31,31,30,31,30,31};33 if( (year % 4 == 0 && year % 100 !=0) || (year % 400 == 0) )34 {35 a[1]=29;36 }37 int i,sum=0;38 for(i=0;i