/* The town's records, as kept by the town clerk. */ #ifndef RECORDS_H #define RECORDS_H #define MAX_ROWS 256 #define MAX_FIELDS 10 #define FIELD 64 struct record { int rows; int fields[MAX_ROWS]; char field[MAX_ROWS][MAX_FIELDS][FIELD]; }; struct day { int y, m, d; }; /* Rows of a record. Fields are separated by "|". Lines starting with # are the clerk's. */ const struct record *read_record(const char *name); /* Minutes past midnight, from HH:MM. */ int clock_time(const char *hhmm); /* A day, from YYYY-MM-DD. */ struct day parse_day(const char *iso); int same_day(struct day a, struct day b); /* Day of the week. Monday is 0. */ int weekday(struct day day); /* Days since 1 January 1970. */ int day_number(struct day day); /* The first of a month, counted from January 1900, which is month 0. */ struct day month_day(int month); /* The month a day is in, counted from January 1900. */ int month_of(struct day day); /* Whether something in force from one date until another is in force on a day. * It starts on its first date and has stopped by its second. "-" means it has not stopped. */ int in_force(const char *from, const char *until, struct day day); /* A day named in the calendar: "Founded" or "Census taken". */ struct day calendar(const char *what); /* The day the census was taken. */ struct day census_day(void); #endif