- - , / ( , epoch, 01.01.1970).
, , . , .
namespace {
class month_database {
public:
month_database () {
days_into_year[0] = 0;
for (int i=0; i<11; i++) {
days_into_year[i+1] = days_into_year[i] + days_in_month[i];
}
};
int start_day (int month, int year) const {
if ( (year % 4) == 0 && month > 2) {
return days_into_year[month-1] + 1;
} else {
return days_into_year[month-1];
}
}
private:
static int const days_in_month[12];
int days_into_year[12];
};
int const month_database::days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
month_database month;
}
start_day, , , , . , , . , , .
February 29 in the Gregorian calendar, the most widely used today, is the date it occurs only once every four years, in years evenly divided by 4, such as 1976, 1996, 2000, 2004, 2008, 2012 or 2016. (Except for a century not divisible by 400, such as 1900).
source
share