| CARVIEW |
Select Language
HTTP/1.1 200 OK
Server: publicfile
Date: Wed, 31 Dec 2025 16:43:22 GMT
Last-Modified: Sun, 17 Dec 2023 19:20:43 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
/*
Public domain.
Like any other piece of software (and information generally),
Cal.HC comes with NO WARRANTY.
This is version 20231217 of Cal.HC.
*/
/*
Example:
#include "Cal.HC"
Cal; // print the monthly calendar for the current date
Cal(NULL,12); // print the monthly calendar for December of the current year
Cal(2000,2); // print the monthly calendar for February 2000
Cal(1865); // print the monthly calendar for the current month for the year 1865;
PrintCal(Now); // this is equivalent to Cal(), but it takes a CDate;
U8 m;
for (m = 1; m < 13; m++) Cal(2022,m); // print a calendar for an entire year
*/
U0 PrintCal(CDate cdt=Now) {
CDateStruct ds;
I64 d, end, i;
cdt.date = FirstDayOfMon(cdt.date);
end = LastDayOfMon(cdt.date);
Date2Struct(&ds,cdt);
"\n %Z",ds.mon-1,"ST_MONTHS";
" %d\n\n",ds.year;
for (i = 0; i < ds.day_of_week; i++) " ";
for (d = 0; (d+cdt.date) <= end; i++, d++) {
if (30 < d) break; // December bug in LastDayOfMon()
if (i == 7) {
"\n";
i = 0;
}
" %2d", 1+d;
}
"\n\n";
}
U0 Cal(I64 year=NULL, U8 month=NULL) {
CDate cdt = Now;
CDateStruct ds;
if (12 < month) {
"Cal: FATAL: please enter valid month (1-12)\n";
return;
}
Date2Struct(&ds,cdt);
ds.day_of_mon = 1;
if (year) ds.year = year;
if (month) ds.mon = month;
cdt = Struct2Date(&ds);
PrintCal(cdt);
}