Object | +---DCalendar
The calendar class implements a number of methods for generating calendars.
#include <stdio.h> #include "ofc/DCalendar.h" int main(int argc, char *argv[]) { DCalendar *cal1 = [DCalendar alloc]; DCalendar *cal2 = [DCalendar new ]; DText *str; [cal1 init :2008]; // Init with year 2008 str = [cal1 toText]; // Generate a year calendar of 2008 printf("%s\n", [str cstring]); // Print the calendar [str free]; [cal2 year :2008]; // Set with year and month [cal2 month :1 ]; str = [cal2 toText]; // Generate a month calendar of jan. 2008 printf("%s\n", [str cstring]); // Print the calendar [str free]; // Some general calendar methods printf("2008 is a %s year\n", ([DCalendar isLeapYear :2008] ? "leap" : "normal")); printf("Leap years in 2000-2008:%d\n", [DCalendar leapYears :2000 :2008]); printf("Days in Month (2008-02):%d\n", [DCalendar daysInMonth :2008 :2]); printf("Day in week (2008-02-29):%d\n", [DCalendar weekDay :2008 :2 :29]); // Friday [cal1 free]; // Cleanup [cal2 free]; return 0; }