[gnome-calendar] date formats: Use g_date_time_format()
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] date formats: Use g_date_time_format()
- Date: Thu, 1 Jun 2017 14:38:18 +0000 (UTC)
commit 2263fc9478e2ce110c915863f7710242d7a67fb8
Author: Rafal Luzynski <digitalfreak lingonborough com>
Date: Tue Mar 28 22:07:37 2017 +0200
date formats: Use g_date_time_format()
Don't hardcode month-day order, use g_date_time_format() and
mark the format string for translation and let translators choose
their preferred formats.
This patch also removes context from the existing "%B %d" date
format because it is unnecessary and this allows the format to be
reused by the patch.
https://bugzilla.gnome.org/show_bug.cgi?id=780629
src/gcal-quick-add-popover.c | 12 ++++++------
src/views/gcal-month-view.c | 12 +++++++-----
src/views/gcal-year-view.c | 20 +++++++++++++++-----
3 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/src/gcal-quick-add-popover.c b/src/gcal-quick-add-popover.c
index 4129b50..695c087 100644
--- a/src/gcal-quick-add-popover.c
+++ b/src/gcal-quick-add-popover.c
@@ -228,10 +228,10 @@ update_header (GcalQuickAddPopover *self)
stm_date = icaltimetype_to_tm (dtstart);
/* Translators:
- * this is the format string for representing a date consisting of a month name
- * and a date of month.
+ * this is the format string for representing a date consisting of a month
+ * name and a day of month.
*/
- e_utf8_strftime_fix_am_pm (start, 64, C_("event date format", "%B %d"), &stm_date);
+ e_utf8_strftime_fix_am_pm (start, 64, _("%B %d"), &stm_date);
if (self->date_end)
{
@@ -258,10 +258,10 @@ update_header (GcalQuickAddPopover *self)
{
etm_date = icaltimetype_to_tm (dtend);
/* Translators:
- * this is the format string for representing a date consisting of a month name
- * and a date of month.
+ * this is the format string for representing a date consisting of a month
+ * name and a day of month.
*/
- e_utf8_strftime_fix_am_pm (end, 64, C_("event date format", "%B %d"), &etm_date);
+ e_utf8_strftime_fix_am_pm (end, 64, _("%B %d"), &etm_date);
title_date = g_strdup_printf (_("New Event from %s to %s"), start, end);
}
diff --git a/src/views/gcal-month-view.c b/src/views/gcal-month-view.c
index c6c39c7..19ba55d 100644
--- a/src/views/gcal-month-view.c
+++ b/src/views/gcal-month-view.c
@@ -199,7 +199,7 @@ get_cell_position (GcalMonthView *self,
}
static void
rebuild_popover_for_day (GcalMonthView *self,
- gint day)
+ GDateTime *day)
{
GcalSubscriberViewPrivate *ppriv;
GList *l;
@@ -222,7 +222,7 @@ rebuild_popover_for_day (GcalMonthView *self,
ppriv = GCAL_SUBSCRIBER_VIEW (self)->priv;
- label_title = g_strdup_printf ("%s %d", gcal_get_month_name (self->date->month - 1), day);
+ label_title = g_date_time_format (day, _("%B %d"));
gtk_label_set_text (GTK_LABEL (self->popover_title), label_title);
g_free (label_title);
@@ -254,7 +254,7 @@ rebuild_popover_for_day (GcalMonthView *self,
dt_start = g_date_time_new (tz,
g_date_time_get_year (current_date),
g_date_time_get_month (current_date),
- day,
+ g_date_time_get_day_of_month (day),
0, 0, 0);
dt_end = g_date_time_add_days (dt_start, 1);
@@ -320,7 +320,9 @@ rebuild_popover_for_day (GcalMonthView *self,
child_widget = gtk_bin_get_child (GTK_BIN (self->overflow_popover));
gtk_widget_set_size_request (child_widget, 200, -1);
- g_object_set_data (G_OBJECT (self->overflow_popover), "selected-day", GINT_TO_POINTER (day));
+ g_object_set_data (G_OBJECT (self->overflow_popover),
+ "selected-day",
+ GINT_TO_POINTER (g_date_time_get_day_of_month (day)));
}
static gboolean
@@ -347,7 +349,7 @@ show_popover_for_position (GcalMonthView *self,
{
self->hovered_overflow_indicator = self->pressed_overflow_indicator;
- rebuild_popover_for_day (GCAL_MONTH_VIEW (widget), g_date_time_get_day_of_month (end_dt));
+ rebuild_popover_for_day (GCAL_MONTH_VIEW (widget), end_dt);
gtk_widget_show_all (self->overflow_popover);
gtk_widget_queue_draw (widget);
diff --git a/src/views/gcal-year-view.c b/src/views/gcal-year-view.c
index bd5effc..e15814a 100644
--- a/src/views/gcal-year-view.c
+++ b/src/views/gcal-year-view.c
@@ -276,10 +276,19 @@ update_no_events_page (GcalYearView *year_view)
}
else
{
- title = g_strdup_printf ("%s %d%s",
- gcal_get_month_name (year_view->start_selected_date->month - 1),
- year_view->start_selected_date->day,
- has_range ? "…" : "");
+ if (has_range)
+ {
+ /* Translators: This is a date format in the sidebar of the year
+ * view when the selection starts at the specified day and the
+ * end is unspecified. */
+ title = g_date_time_format (start_selected_date, _("%B %d…"));
+ }
+ else
+ {
+ /* Translators: This is a date format in the sidebar of the year
+ * view when there is only one specified day selected. */
+ title = g_date_time_format (start_selected_date, _("%B %d"));
+ }
}
gtk_label_set_text (GTK_LABEL (year_view->no_events_title), title);
@@ -499,7 +508,8 @@ update_sidebar_headers (GtkListBoxRow *row,
if (datetime_compare_date (dt, now) == 0)
label_str = g_strdup (_("Today"));
else
- label_str = g_strdup_printf ("%s %d", gcal_get_month_name (date.month - 1), date.day);
+ /* Translators: This is a date format in the sidebar of the year view. */
+ label_str = g_date_time_format (dt, _("%B %d"));
label = gtk_label_new (label_str);
gtk_style_context_add_class (gtk_widget_get_style_context (label), "sidebar-header");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]