In this simple example, we'll explain how to format the label displaying month and year, and also set weekday names.
To format month and year label, we need to create a callback function to create a string given the selected time, declared under a struct tm .
struct tm , declared on time.h, is a structure composed by nine integers:
strftime. We will get abbreviated month (b) and year (y) (check strftime manpage for more) in our example: We need to alloc the string to be returned, and calendar widget will free it when it's not needed, what is done by strdup. So let's register our callback to calendar object:
To set weekday names, we should declare them as an array of strings:
And finally set them to calendar:
Our example will look like this:
See the full source code calendar_example_02.c here.