Calendar - Layout strings formatting.

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:

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:

elm_calendar_format_function_set(cal, _format_month_year);

To set weekday names, we should declare them as an array of strings:

const char *weekdays[] =
"S", "M", "T", "W", "T", "F", "S"

And finally set them to calendar:

Our example will look like this:


See the full source code calendar_example_02.c here.