From eba407c83a55de56da0c9675d9b33064b8d5061a Mon Sep 17 00:00:00 2001 From: tasn Date: Tue, 15 Feb 2011 13:37:28 +0000 Subject: [PATCH] Elementary calendar: Weekday names are now taken from locale. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@57048 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/lib/elm_calendar.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/lib/elm_calendar.c b/src/lib/elm_calendar.c index 7207997..b66ff80 100644 --- a/src/lib/elm_calendar.c +++ b/src/lib/elm_calendar.c @@ -62,6 +62,8 @@ static const char *widtype = NULL; static void _on_focus_hook(void *data, Evas_Object *obj); static void _mirrored_set(Evas_Object *obj, Eina_Bool rtl); +/* Should not be translated, it's used if we failed + * getting from locale. */ static const char *_days_abbrev[] = { "Sun", "Mon", "Tue", "Wed", @@ -720,6 +722,7 @@ EAPI Evas_Object * elm_calendar_add(Evas_Object *parent) { time_t current_time; + time_t weekday = 259200; /* Just the first sunday since epoch */ Evas_Object *obj; Widget_Data *wd; int i, t; @@ -768,7 +771,24 @@ elm_calendar_add(Evas_Object *parent) "*", _day_selected, obj); for (i = 0; i < 7; i++) - wd->weekdays[i] = eina_stringshare_add(_days_abbrev[i]); + { + /* FIXME: I'm not aware of a known max, so if it fails, + * just make it larger. :| */ + char buf[20]; + /* I don't know of a better way of doing it */ + if (strftime(buf, sizeof(buf), "%a", gmtime(&weekday))) + { + wd->weekdays[i] = eina_stringshare_add(buf); + } + else + { + /* If we failed getting day, get a default value */ + wd->weekdays[i] = _days_abbrev[i]; + WRN("Failed getting weekday name for '%s' from locale.", + _days_abbrev[i]); + } + weekday += 86400; /* Advance by a day */ + } current_time = time(NULL); localtime_r(¤t_time, &wd->selected_time); -- 2.7.4