Implement DATESUM, DATEDIFF functions.
[pspp-builds.git] / src / data / calendar.c
index 3a38f1265fae0b3013d68840a8ea62aaae609b4d..c3d9d8e6ea00728cca253c4be18dbc01527dc5f6 100644 (file)
@@ -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];
+}