From d54fe7c1f704a63824c5bfa0ece65245572e9b27 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 4 Mar 2015 21:21:30 -0500 Subject: Initial commit --- src/libcf/month_day.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/libcf/month_day.c (limited to 'src/libcf/month_day.c') 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; +} -- cgit