From 0fad515e1b65662306219464f00485817fc75511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Jard=C3=B3n?= Date: Fri, 2 Sep 2011 16:43:16 +0100 Subject: Warning when the user use a date format not supported We are using the g_date_time_format () function and the format strings understood by this function are a subset of the strftime() format language. --- src/indicator-datetime.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/indicator-datetime.c b/src/indicator-datetime.c index 59bcaf3..f773159 100644 --- a/src/indicator-datetime.c +++ b/src/indicator-datetime.c @@ -215,7 +215,7 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) PROP_TIME_FORMAT, g_param_spec_int(PROP_TIME_FORMAT_S, "A choice of which format should be used on the panel", - "Chooses between letting the locale choose the time, 12-hour time, 24-time or using the custom string passed to strftime().", + "Chooses between letting the locale choose the time, 12-hour time, 24-time or using the custom string passed to g_date_time_format().", SETTINGS_TIME_LOCALE, /* min */ SETTINGS_TIME_CUSTOM, /* max */ SETTINGS_TIME_LOCALE, /* default */ @@ -245,7 +245,7 @@ indicator_datetime_class_init (IndicatorDatetimeClass *klass) PROP_CUSTOM_TIME_FORMAT, g_param_spec_string(PROP_CUSTOM_TIME_FORMAT_S, "The format that is used to show the time on the panel.", - "A format string in the form used to pass to strftime to make a string for displaying on the panel.", + "A format string in the form used to pass to g_date_time_format() to make a string for displaying on the panel.", DEFAULT_TIME_FORMAT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); @@ -775,6 +775,12 @@ set_label_to_time_in_zone (IndicatorDatetime * self, GtkLabel * label, } else { timestr = g_date_time_format(datetime_now, format); + if (timestr == NULL) { + g_warning ("The custom date format is not valid, check the + g_date_time_format() documentation for the supported + format specifiers "); + timestr = g_strdup ("Date format not supported"); + } } gboolean use_markup = FALSE; -- cgit v1.2.3