jpeg pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=e85c92662bfec6a88bb7d2d091682daa429acba0
commit e85c92662bfec6a88bb7d2d091682daa429acba0 Author: Woochan Lee <[email protected]> Date: Tue Apr 18 10:17:06 2017 +0900 elm_calendar: Improve code quality. Summary: The values(259200, 86400) are hard to know the meaning. And we don't have to call gmtime() in for loop. Test Plan: elementary_test -> calendar Reviewers: jpeg, Hermet, shilpasingh, cedric Reviewed By: cedric Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D4717 --- src/lib/elementary/elm_calendar.c | 41 +++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/lib/elementary/elm_calendar.c b/src/lib/elementary/elm_calendar.c index e25ebf2..aeb5eb1 100644 --- a/src/lib/elementary/elm_calendar.c +++ b/src/lib/elementary/elm_calendar.c @@ -709,40 +709,35 @@ _set_headers(Evas_Object *obj) { static char part[] = "ch_0.text"; int i; + struct tm *t; + time_t temp; ELM_CALENDAR_DATA_GET(obj, sd); - time_t weekday = 259200; /* Just the first sunday since epoch */ elm_layout_freeze(obj); sd->filling = EINA_TRUE; - if (!sd->weekdays_set) + t = gmtime(&temp); + if (t && !sd->weekdays_set) { + t->tm_wday = 0; for (i = 0; i < ELM_DAY_LAST; i++) { - struct tm *info; - - /* I don't know of a better way of doing it */ - info = gmtime(&weekday); - if (info) + char *buf; + buf = eina_strftime("%a", t); + if (buf) { - char *buf; - buf = eina_strftime("%a", info); - if (buf) - { - sd->weekdays[i] = eina_stringshare_add(buf); - free(buf); - } - else - { - /* If we failed getting day, get a default value */ - sd->weekdays[i] = _days_abbrev[i]; - WRN("Failed getting weekday name for '%s' from locale.", - _days_abbrev[i]); - } + sd->weekdays[i] = eina_stringshare_add(buf); + free(buf); } - - weekday += 86400; /* Advance by a day */ + else + { + /* If we failed getting day, get a default value */ + sd->weekdays[i] = _days_abbrev[i]; + WRN("Failed getting weekday name for '%s' from locale.", + _days_abbrev[i]); + } + t->tm_wday++; } } --
