From 98156dccb163fb1716cd507d865e8a16be51bff2 Mon Sep 17 00:00:00 2001 From: ChunEon Park Date: Mon, 16 Apr 2012 06:55:58 +0000 Subject: [PATCH] elementary/datetime - elm_datetime - Open source patch : Separator parsing logic in Datetime is corrected Change Description: [elm_datetime.c] Separator parsing logic is changed in Datetime widget. Predefined set of characters (both global and field specific) are ignored as field separators. Can some one, please review and check-in the code in SVN Elementary. Thanks, Sumanth Singed-Off-By: Sumanth Krishna Mannam SVN revision: 70220 --- src/lib/elm_datetime.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/lib/elm_datetime.c b/src/lib/elm_datetime.c index caecb9a..1873f37 100644 --- a/src/lib/elm_datetime.c +++ b/src/lib/elm_datetime.c @@ -74,19 +74,21 @@ struct _Format_Map char *fmt_char; int def_min; int def_max; + char *ignore_sep; }; // default limits for individual fields static Format_Map mapping[DATETIME_TYPE_COUNT] = { - [ELM_DATETIME_YEAR] = { "Yy", -1, -1 }, - [ELM_DATETIME_MONTH] = { "mbBh", 0, 11 }, - [ELM_DATETIME_DATE] = { "de", 1, 31 }, - [ELM_DATETIME_HOUR] = { "IHkl", 0, 23 }, - [ELM_DATETIME_MINUTE] = { "M", 0, 59 }, - [ELM_DATETIME_AMPM] = { "pP", 0, 1 } + [ELM_DATETIME_YEAR] = { "Yy", -1, -1, "" }, + [ELM_DATETIME_MONTH] = { "mbBh", 0, 11, "" }, + [ELM_DATETIME_DATE] = { "de", 1, 31, "" }, + [ELM_DATETIME_HOUR] = { "IHkl", 0, 23, "" }, + [ELM_DATETIME_MINUTE] = { "M", 0, 59, ":" }, + [ELM_DATETIME_AMPM] = { "pP", 0, 1, "" } }; static const char *multifield_formats = "cxXrRTDF"; +static const char *ignore_separators = "()"; static Datetime_Mod_Api *dt_mod = NULL; static const char *widtype = NULL; @@ -640,7 +642,7 @@ _parse_format(Evas_Object *obj, char *fmt_ptr) { Widget_Data *wd; Datetime_Field *field = NULL; - unsigned int len = 0, idx, location = 0; + unsigned int len = 0, idx = 0, location = 0; char separator[MAX_SEPARATOR_LEN]; char cur; Eina_Bool fmt_parsing = EINA_FALSE, sep_parsing = EINA_FALSE, @@ -678,9 +680,11 @@ _parse_format(Evas_Object *obj, char *fmt_ptr) separator[len] = 0; if (field) eina_stringshare_replace(&field->separator, separator); } + + // ignore the set of chars (global, field specific) as field separators. if (sep_parsing && (len < MAX_SEPARATOR_LEN - 1) && - (field->type != ELM_DATETIME_AMPM) && - (!((field->type == ELM_DATETIME_MINUTE) && (cur ==':')))) + (field->type != ELM_DATETIME_AMPM) && (!strchr(ignore_separators, cur)) && + (!strchr(mapping[idx].ignore_sep, cur))) separator[len++] = cur; if (sep_lookup) sep_parsing = EINA_TRUE; sep_lookup = EINA_FALSE; -- 2.7.4