Implementation in software
integer number_of_days ( month, leap_year_flag) {
switch (month) {
case 1: return (31);
case 2: if (leap_year_flag == 1) then return (29) else return (28);
case 3: return (31);
...
case 12: return (31);
default: return (0);
}