From 4b281e9a5dc3414fd55cb0621ab2a62d11989c01 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 Apr 2011 14:54:57 -0500 Subject: Detect a full day event and print it differently --- src/datetime-service.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/datetime-service.c b/src/datetime-service.c index 6458ae9..eff3cfa 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -860,6 +860,9 @@ update_appointment_menu_items (gpointer user_data) g_free (summary); // Due text + if (time_add_day(ci->start, 1) == ci->end) { + strftime(right, 20, "%A", due); + } else { if (apt_output == SETTINGS_TIME_12_HOUR) { if ((mday == dmday) && (mon == dmon) && (year == dyear)) strftime(right, 20, _(DEFAULT_TIME_12_FORMAT), due); @@ -871,6 +874,7 @@ update_appointment_menu_items (gpointer user_data) else strftime(right, 20, _(DEFAULT_TIME_24_FORMAT_WITH_DAY), due); } + } g_debug("Appointment time: %s, for date %s", right, asctime(due)); dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_RIGHT, right); -- cgit v1.2.3 From 3a5ab9e661b7d7438c6c494b271c6be86a3703e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 Apr 2011 14:58:16 -0500 Subject: Translator comment --- src/datetime-service.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index eff3cfa..66a6cdb 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -861,7 +861,11 @@ update_appointment_menu_items (gpointer user_data) // Due text if (time_add_day(ci->start, 1) == ci->end) { - strftime(right, 20, "%A", due); + /* TRANSLATORS: This is a strftime string for the day for full day events + in the menu. It should most likely be either '%A' for a full text day + (Wednesday) or '%a' for a shortened one (Wed). You should only need to + change for '%a' in the case of langauges with very long day names. */ + strftime(right, 20, _("%A"), due); } else { if (apt_output == SETTINGS_TIME_12_HOUR) { if ((mday == dmday) && (mon == dmon) && (year == dyear)) -- cgit v1.2.3 From 9744a2f892fb78f74e9c942197ca98309a9e2759 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 Apr 2011 15:10:50 -0500 Subject: Pull the full day into a boolean and reformat --- src/datetime-service.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index 66a6cdb..c72b061 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -859,25 +859,33 @@ update_appointment_menu_items (gpointer user_data) g_debug("Summary: %s", summary); g_free (summary); + gboolean full_day = FALSE; + if (vtype == E_CAL_COMPONENT_EVENT) { + time_t start = ci->start; + if (time_add_day(start, 1) == ci->end) { + full_day = TRUE; + } + } + // Due text - if (time_add_day(ci->start, 1) == ci->end) { + if (full_day) { /* TRANSLATORS: This is a strftime string for the day for full day events in the menu. It should most likely be either '%A' for a full text day (Wednesday) or '%a' for a shortened one (Wed). You should only need to change for '%a' in the case of langauges with very long day names. */ strftime(right, 20, _("%A"), due); } else { - if (apt_output == SETTINGS_TIME_12_HOUR) { - if ((mday == dmday) && (mon == dmon) && (year == dyear)) - strftime(right, 20, _(DEFAULT_TIME_12_FORMAT), due); - else - strftime(right, 20, _(DEFAULT_TIME_12_FORMAT_WITH_DAY), due); - } else if (apt_output == SETTINGS_TIME_24_HOUR) { - if ((mday == dmday) && (mon == dmon) && (year == dyear)) - strftime(right, 20, _(DEFAULT_TIME_24_FORMAT), due); - else - strftime(right, 20, _(DEFAULT_TIME_24_FORMAT_WITH_DAY), due); - } + if (apt_output == SETTINGS_TIME_12_HOUR) { + if ((mday == dmday) && (mon == dmon) && (year == dyear)) + strftime(right, 20, _(DEFAULT_TIME_12_FORMAT), due); + else + strftime(right, 20, _(DEFAULT_TIME_12_FORMAT_WITH_DAY), due); + } else if (apt_output == SETTINGS_TIME_24_HOUR) { + if ((mday == dmday) && (mon == dmon) && (year == dyear)) + strftime(right, 20, _(DEFAULT_TIME_24_FORMAT), due); + else + strftime(right, 20, _(DEFAULT_TIME_24_FORMAT_WITH_DAY), due); + } } g_debug("Appointment time: %s, for date %s", right, asctime(due)); dbusmenu_menuitem_property_set (item, APPOINTMENT_MENUITEM_PROP_RIGHT, right); -- cgit v1.2.3 From db8896f805704ea21387cb4acd712901177e1ea3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 Apr 2011 15:11:12 -0500 Subject: Use stack memory instead of the global to avoid it getting modified --- src/datetime-service.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index c72b061..0ceb975 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -802,9 +802,10 @@ update_appointment_menu_items (gpointer user_data) DbusmenuMenuitem * item; ECalComponentVType vtype = e_cal_component_get_vtype (ecalcomp); + struct tm due_data = {0}; struct tm *due = NULL; - if (vtype == E_CAL_COMPONENT_EVENT) due = localtime(&ci->start); - else if (vtype == E_CAL_COMPONENT_TODO) due = localtime(&ci->end); + if (vtype == E_CAL_COMPONENT_EVENT) due = localtime_r(&ci->start, &due_data); + else if (vtype == E_CAL_COMPONENT_TODO) due = localtime_r(&ci->end, &due_data); else continue; const int dmday = due->tm_mday; -- cgit v1.2.3 From 76760205d4a4ab209515b7333794cd059ecda82a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 Apr 2011 15:22:12 -0500 Subject: Use gmtime for full day events. --- src/datetime-service.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/datetime-service.c b/src/datetime-service.c index 0ceb975..5e8d312 100644 --- a/src/datetime-service.c +++ b/src/datetime-service.c @@ -870,11 +870,14 @@ update_appointment_menu_items (gpointer user_data) // Due text if (full_day) { + struct tm fulldaytime = {0}; + gmtime_r(&ci->start, &fulldaytime); + /* TRANSLATORS: This is a strftime string for the day for full day events in the menu. It should most likely be either '%A' for a full text day (Wednesday) or '%a' for a shortened one (Wed). You should only need to change for '%a' in the case of langauges with very long day names. */ - strftime(right, 20, _("%A"), due); + strftime(right, 20, _("%A"), &fulldaytime); } else { if (apt_output == SETTINGS_TIME_12_HOUR) { if ((mday == dmday) && (mon == dmon) && (year == dyear)) -- cgit v1.2.3