X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcalendar.c;h=c3d9d8e6ea00728cca253c4be18dbc01527dc5f6;hb=a1fa03b1638263a959df0b2943478a0a4ca4b11a;hp=3a38f1265fae0b3013d68840a8ea62aaae609b4d;hpb=8acca2de53c1852f38726f70fc6516b34732a79f;p=pspp diff --git a/src/data/calendar.c b/src/data/calendar.c index 3a38f1265f..c3d9d8e6ea 100644 --- a/src/data/calendar.c +++ b/src/data/calendar.c @@ -210,3 +210,14 @@ calendar_offset_to_mday (int ofs) calendar_offset_to_gregorian (ofs, &y, &m, &d, &yd); return d; } + +/* Returns the number of days in the specified month. */ +int +calendar_days_in_month (int y, int m) +{ + static const int days_per_month[12] + = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + + assert (m >= 1 && m <= 12); + return m == 2 && is_leap_year (y) ? 29 : days_per_month[m - 1]; +}