diff options
Diffstat (limited to 'src/libcf/month_day.c')
-rw-r--r-- | src/libcf/month_day.c | 19 |
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; +} |