efl_ui_clock: Parses the format recursively.

Summary:
Some of locale formats convert as extension format.
For example,
             uk_UA d_t_fmt is "%a, %d-%b-%Y %X %z".
             The %X will convert as %T.
             The %T format has to convert one more time to convert as %H:%M:%S.

ref : https://lh.2xlibre.net/locale/uk_UA/

We need to parse the format recursively to support that kind of case.

@fix

Test Plan:
Change the locale as uk_UA.
Run elementary_test -> datetime
See the time field is not appear.

Reviewers: jpeg, cedric

Subscribers: cedric, jpeg

Differential Revision: https://phab.enlightenment.org/D5021
This commit is contained in:
Woochan Lee 2017-08-22 14:17:41 +09:00 committed by Jean-Philippe Andre
parent b433592b03
commit 4656f98e22
1 changed files with 28 additions and 22 deletions

View File

@ -202,33 +202,39 @@ static void
_expand_format(char *dt_fmt)
{
char *ptr, *expanded_fmt, ch;
unsigned int idx = 0, len = 0;
unsigned int idx, len = 0;
char buf[EFL_UI_CLOCK_MAX_FORMAT_LEN] = {0, };
Eina_Bool fmt_char = EINA_FALSE;
Eina_Bool fmt_char, fmt_expanded;
ptr = dt_fmt;
while ((ch = *ptr))
{
if ((fmt_char) && (strchr(multifield_formats, ch)))
{
/* replace the multi-field format characters with
* corresponding expanded format */
expanded_fmt = _expanded_fmt_str_get(ch);
len = strlen(expanded_fmt);
buf[--idx] = 0;
strncat(buf, expanded_fmt, len);
idx += len;
}
else buf[idx++] = ch;
do {
idx = 0;
fmt_char = EINA_FALSE;
fmt_expanded = EINA_FALSE;
ptr = dt_fmt;
while ((ch = *ptr))
{
if ((fmt_char) && (strchr(multifield_formats, ch)))
{
/* replace the multi-field format characters with
* corresponding expanded format */
expanded_fmt = _expanded_fmt_str_get(ch);
len = strlen(expanded_fmt);
if (len > 0) fmt_expanded = EINA_TRUE;
buf[--idx] = 0;
strncat(buf, expanded_fmt, len);
idx += len;
}
else buf[idx++] = ch;
if (ch == '%') fmt_char = EINA_TRUE;
else fmt_char = EINA_FALSE;
if (ch == '%') fmt_char = EINA_TRUE;
else fmt_char = EINA_FALSE;
ptr++;
}
ptr++;
}
buf[idx] = 0;
strncpy(dt_fmt, buf, EFL_UI_CLOCK_MAX_FORMAT_LEN);
buf[idx] = 0;
strncpy(dt_fmt, buf, EFL_UI_CLOCK_MAX_FORMAT_LEN);
} while (fmt_expanded);
}
static void