aboutsummaryrefslogtreecommitdiff
path: root/src/libcf/month_day.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-03-04 21:21:30 -0500
commitd54fe7c1f704a63824c5bfa0ece65245572e9b27 (patch)
treeafc52015ffc2c74e0266653eecef1c8ef8ba5d91 /src/libcf/month_day.c
downloadcalfuse-d54fe7c1f704a63824c5bfa0ece65245572e9b27.tar.gz
Initial commit
Diffstat (limited to 'src/libcf/month_day.c')
-rw-r--r--src/libcf/month_day.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libcf/month_day.c b/src/libcf/month_day.c
new file mode 100644
index 0000000..1ecfae1
--- /dev/null
+++ b/src/libcf/month_day.c
@@ -0,0 +1,19 @@
+/* month_day: return month,day from day of year */
+/* 07/21/04 1.4 wvd Add () to defn of leap */
+
+#include "calfuse.h"
+
+void month_day(int year, int yearday, int *pmonth, int *pday)
+{
+ static char daytab[2][13]={
+ {0,31,28,31,30,31,30,31,31,30,31,30,31},
+ {0,31,29,31,30,31,30,31,31,30,31,30,31}
+ };
+ int i, leap;
+
+ leap = ((year%4 == 0 && year%100 != 0) || year%400 == 0);
+ for (i=1; yearday>daytab[leap][i]; i++)
+ yearday-=daytab[leap][i];
+ *pmonth=i;
+ *pday=yearday;
+}