leapc
Loading...
Searching...
No Matches
days.c
1#include "days.h"
2#include "leap.h"
3
4#include <time.h>
5#include <memory.h>
6
7double mkdays(int year, int mon, int mday) {
8 struct tm tm;
9 (void)memset(&tm, 0, sizeof(tm));
10 tm.tm_year = year - 1900;
11 tm.tm_mon = mon - 1;
12 tm.tm_mday = mday;
13 return mktime(&tm) / (24.0 * 60 * 60);
14}
15
16double diff_days(int year1, int year0) {
17 double x = mkdays(year1, 1, 1) - mkdays(year0, 1, 1);
18 int y = leap_day(year1) - leap_day(year0);
19 return x - y;
20}
Function prototypes for making days from standard time and computing day differences.
Leap year function prototypes.
int leap_day(int year)
Counts leap-adjusted days up to some year.
Definition leap.c:48