Datetime
This feature is supported in mobile applications only.
The datetime component displays and adds date and time values.
For more information, see the Datetime API.
Figure: Datetime selection
Figure: Datetime hierarchy
Adding a Datetime Component
Create the datetime component with the elm_datetime_add() function. It is possible to select the visible fields with the elm_datetime_field_visible_set() function. The following fields can be controlled:
- ELM_DATETIME_YEAR: Year field
- ELM_DATETIME_MONTH: Month field
- ELM_DATETIME_DATE: Date field
- ELM_DATETIME_HOUR: Hour field
- ELM_DATETIME_MINUTE: Minute field
- ELM_DATETIME_AMPM: AM/PM field
The following example shows how to create a datetime component and set the HOUR and MINUTE fields visible.
Evas_Object *datetime, *parent; datetime = elm_datetime_add(parent); elm_datetime_field_visible_set(datetime, ELM_DATETIME_HOUR, EINA_TRUE); elm_datetime_field_visible_set(datetime, ELM_DATETIME_MINUTE, EINA_TRUE); elm_datetime_field_visible_set(datetime, ELM_DATETIME_YEAR, EINA_FALSE); elm_datetime_field_visible_set(datetime, ELM_DATETIME_MONTH, EINA_FALSE); elm_datetime_field_visible_set(datetime, ELM_DATETIME_DATE, EINA_FALSE); elm_datetime_field_visible_set(datetime, ELM_DATETIME_AMPM, EINA_FALSE);
Using the Datetime Styles
The following styles are available:
- date_layout
- time_layout
- time_layout_24hr
To set the date_layout style to the datetime component:
elm_object_style_set(datetime, "date_layout");
Setting the Datetime Format
The format of the date and time can be configured with the elm_datetime_format_set() function using a combination of allowed Libc date format specifiers. In the following example, the format is set to DD MM YY.
elm_datetime_format_set(datetime, "%d%B%Y");
For a complete list available options, see the Datetime API.
Using the Datetime Callbacks
A callback can be registered on the changed signal to detect when the datetime field values are changed. The event_info parameter is NULL.
{ evas_object_smart_callback_add(datetime, "changed", changed_cb, data); } // Callback function for the "changed" signal // This callback is called when the datetime fields change void changed_cb(void *data, Evas_Object *obj, void *event_info) { dlog_print(DLOG_INFO, LOG_TAG, "Datetime field changed. \n"); }
The language,changed signal is emitted when the system locale changes.
UX Issue Since Tizen 2.3
- date_layout (default): Year, month, day
- time_layout: Hour, minute, AM/PM button
- time_layout_24hr: Hour, minute
The elm_datetime component needs a full-length format that includes the year, month, day, hour, minute, and AM/PM. Each style then shows specific fields according their style, limited by the UX concept. If you call the elm_datetime_field_visible_set() function for a field that is not supported in the style, it does not work.
Note |
---|
Except as noted, this content is licensed under LGPLv2.1+. |