Datetime widget example

This code places three Elementary Datetime widgets on a window, each of them exemplifying the widget's different usage.

The first of them is "only Date display":

//datetime showing only DATE
datetime = elm_datetime_add(bx);
evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, datetime);
evas_object_show(datetime);

For "only Time display", see the second datetime:

//datetime showing only TIME
datetime = elm_datetime_add(bx);
evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
elm_datetime_field_visible_set(datetime, ELM_DATETIME_YEAR, EINA_FALSE);
elm_box_pack_end(bx, datetime);
evas_object_show(datetime);

The third one will display datetime shows both Date and Time, corresponding format will be taken from system locale. Note, besides, that the strings are different for different language settings.

Datetime format can be programmatically set by using elm_datetime_format_set():

//datetime showing both DATE and TIME
datetime = elm_datetime_add(bx);
evas_object_size_hint_weight_set(datetime, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(datetime, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(bx, datetime);
evas_object_show(datetime);
The default format of any locale consists:

This is how the example program's window looks like with the datetime widget showing only date, only time and both date & time:

datetime_example.png

See the full source code for this example.