elementary/datetime - Elm_datetime open source patch : Datetime enhancements
authorhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 2 Apr 2012 06:20:01 +0000 (06:20 +0000)
committerhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 2 Apr 2012 06:20:01 +0000 (06:20 +0000)
Change Description:
- Year min/max values are moved to elm_config.
- Format specifier must come along with % followed by any separator. ( % 123d is not supported but %d will denote Date format specifier)
- Field separator can constitute multiple spaces, Space followed by any other non format specifier is also treated as the separator till its max length. ( %d x/ %b #2 format displays 27 x/ Mar #2 )

Thanks, Sumanth

Submitted-By-Off Sumanth Krishna Mannam<sumanth.m@samsung.com>

git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@69846 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

config/default/base.src
config/illume/base.src
src/lib/elm_config.c
src/lib/elm_datetime.c
src/lib/elm_datetime.h
src/lib/elm_priv.h

index 53c15cf..932ce2b 100644 (file)
@@ -59,6 +59,8 @@ group "Elm_Config" struct {
   value "week_start" int: 1;
   value "weekend_start" int: 6;
   value "weekend_len" int: 2;
   value "week_start" int: 1;
   value "weekend_start" int: 6;
   value "weekend_len" int: 2;
+  value "year_min" int: 2;
+  value "year_max" int: 137;
   group "color_palette" list {
      group "Elm_Custom_Palette" struct {
         value "palette_name" string: "default";
   group "color_palette" list {
      group "Elm_Custom_Palette" struct {
         value "palette_name" string: "default";
index 2f01b06..1669ce4 100644 (file)
@@ -59,6 +59,8 @@ group "Elm_Config" struct {
   value "week_start" int: 1;
   value "weekend_start" int: 6;
   value "weekend_len" int: 2;
   value "week_start" int: 1;
   value "weekend_start" int: 6;
   value "weekend_len" int: 2;
+  value "year_min" int: 2;
+  value "year_max" int: 137;
   group "color_palette" list {
      group "Elm_Custom_Palette" struct {
         value "palette_name" string: "default";
   group "color_palette" list {
      group "Elm_Custom_Palette" struct {
         value "palette_name" string: "default";
index 29cdac3..f4744a5 100644 (file)
@@ -382,6 +382,8 @@ _desc_init(void)
    ELM_CONFIG_VAL(D, T, week_start, T_INT);
    ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
    ELM_CONFIG_VAL(D, T, weekend_len, T_INT);
    ELM_CONFIG_VAL(D, T, week_start, T_INT);
    ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
    ELM_CONFIG_VAL(D, T, weekend_len, T_INT);
+   ELM_CONFIG_VAL(D, T, year_min, T_INT);
+   ELM_CONFIG_VAL(D, T, year_max, T_INT);
    ELM_CONFIG_LIST(D, T, color_palette, _config_color_palette_edd);
 #undef T
 #undef D
    ELM_CONFIG_LIST(D, T, color_palette, _config_color_palette_edd);
 #undef T
 #undef D
@@ -1034,6 +1036,8 @@ _config_load(void)
    _elm_config->week_start = 1; /* monday */
    _elm_config->weekend_start = 6; /* saturday */
    _elm_config->weekend_len = 2;
    _elm_config->week_start = 1; /* monday */
    _elm_config->weekend_start = 6; /* saturday */
    _elm_config->weekend_len = 2;
+   _elm_config->year_min = 2;
+   _elm_config->year_max = 137;
    _elm_config->color_palette = NULL;
 }
 
    _elm_config->color_palette = NULL;
 }
 
index 1d76dc8..f43eec1 100644 (file)
@@ -77,8 +77,8 @@ struct _Format_Map
 };
 
 // default limits for individual fields
 };
 
 // default limits for individual fields
-static const Format_Map mapping[DATETIME_TYPE_COUNT] = {
-   [ELM_DATETIME_YEAR]   =  { "Yy",   0, 137 },
+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_MONTH]  =  { "mbBh", 0,  11  },
    [ELM_DATETIME_DATE]   =  { "de",   1,  31  },
    [ELM_DATETIME_HOUR]   =  { "IHkl", 0,  23  },
@@ -652,6 +652,7 @@ _parse_format(Evas_Object *obj, char *fmt_ptr)
      {
         if (fmt_parsing)
           {
      {
         if (fmt_parsing)
           {
+             fmt_parsing = EINA_FALSE;
              for (idx = 0; idx < DATETIME_TYPE_COUNT; idx++)
                {
                   if (strchr(mapping[idx].fmt_char, cur))
              for (idx = 0; idx < DATETIME_TYPE_COUNT; idx++)
                {
                   if (strchr(mapping[idx].fmt_char, cur))
@@ -663,23 +664,21 @@ _parse_format(Evas_Object *obj, char *fmt_ptr)
                        field->fmt[1] = cur;
                        field->fmt_exist = EINA_TRUE;
                        field->location = location++;
                        field->fmt[1] = cur;
                        field->fmt_exist = EINA_TRUE;
                        field->location = location++;
-                       fmt_parsing = EINA_FALSE;
                        sep_lookup = EINA_TRUE;
                        len = 0;
                        break;
                     }
                }
           }
                        sep_lookup = EINA_TRUE;
                        len = 0;
                        break;
                     }
                }
           }
-        if (cur == ' ') separator[len++] = cur;
-        else if (cur == '%') fmt_parsing = EINA_TRUE;
-        if ((cur == ' ') || (cur == '%'))
+        if (cur == '%')
           {
           {
+             fmt_parsing = EINA_TRUE;
              sep_parsing = EINA_FALSE;
              // set the separator to previous field
              separator[len] = 0;
              if (field) eina_stringshare_replace(&field->separator, separator);
           }
              sep_parsing = EINA_FALSE;
              // set the separator to previous field
              separator[len] = 0;
              if (field) eina_stringshare_replace(&field->separator, separator);
           }
-        if (sep_parsing && (len < MAX_SEPARATOR_LEN-1) &&
+        if (sep_parsing && (len < MAX_SEPARATOR_LEN - 1) &&
             (field->type != ELM_DATETIME_AMPM) &&
             (!((field->type == ELM_DATETIME_MINUTE) && (cur ==':'))))
            separator[len++] = cur;
             (field->type != ELM_DATETIME_AMPM) &&
             (!((field->type == ELM_DATETIME_MINUTE) && (cur ==':'))))
            separator[len++] = cur;
@@ -767,6 +766,8 @@ _field_list_init(Evas_Object *obj)
    t = time(NULL);
    localtime_r(&t, &wd->curr_time);
 
    t = time(NULL);
    localtime_r(&t, &wd->curr_time);
 
+   mapping[ELM_DATETIME_YEAR].def_min = _elm_config->year_min;
+   mapping[ELM_DATETIME_YEAR].def_max = _elm_config->year_max;
    for (idx = 0; idx < DATETIME_TYPE_COUNT; idx++)
      {
         field = wd->field_list + idx;
    for (idx = 0; idx < DATETIME_TYPE_COUNT; idx++)
      {
         field = wd->field_list + idx;
index 2ac981c..042cdc9 100644 (file)
     * for AM/PM field.
     *
     * Each separator can be a maximum of 6 UTF-8 bytes.
     * for AM/PM field.
     *
     * Each separator can be a maximum of 6 UTF-8 bytes.
-    * Space is also taken as a separator but it can come only once for each field.
+    * Space is also taken as a separator.
     *
     * Following are the allowed set of format specifiers for each datetime field.
     *
     *
     * Following are the allowed set of format specifiers for each datetime field.
     *
     * for AM/PM field.
     *
     * Each separator can be a maximum of 6 UTF-8 bytes.
     * for AM/PM field.
     *
     * Each separator can be a maximum of 6 UTF-8 bytes.
-    * Space is also taken as a separator but it can come only once for each field.
+    * Space is also taken as a separator.
     *
     * Following are the allowed set of format specifiers for each datetime field.
     *
     *
     * Following are the allowed set of format specifiers for each datetime field.
     *
index e3061ae..f931bc0 100644 (file)
@@ -168,6 +168,8 @@ struct _Elm_Config
    int           week_start;
    int           weekend_start;
    int           weekend_len;
    int           week_start;
    int           weekend_start;
    int           weekend_len;
+   int           year_min;
+   int           year_max;
    Eina_List    *color_palette;
 
    /* Not part of the EET file */
    Eina_List    *color_palette;
 
    /* Not part of the EET file */