After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 703321 - respect GNOME's 12/24-hour time setting
respect GNOME's 12/24-hour time setting
Status: RESOLVED FIXED
Product: gnome-calendar
Classification: Applications
Component: General
unspecified
Other Linux
: Normal normal
: 3.26
Assigned To: GNOME Calendar maintainers
GNOME Calendar maintainers
Depends on:
Blocks:
 
 
Reported: 2013-06-29 17:18 UTC by Adam Dingle
Modified: 2017-04-17 18:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Respecting gnome's 12/24 hour format. (1.01 KB, patch)
2016-03-05 11:21 UTC, sadath.anwar17
needs-work Details | Review
Edit dialog: Respecting GNOME's 12/24 hour format (4.53 KB, patch)
2016-03-14 16:21 UTC, sadath.anwar17
none Details | Review
Edit dialog: Respecting GNOME's 12/24 hour format (4.33 KB, patch)
2016-03-14 20:08 UTC, sadath.anwar17
none Details | Review
Edit dialog: Respecting GNOME's 12/24 hour format (4.34 KB, patch)
2016-03-14 20:34 UTC, sadath.anwar17
committed Details | Review

Description Adam Dingle 2013-06-29 17:18:23 UTC
GNOME's Date & Time control center applet allows me to choose either 12-hour (AM/PM) or 24-hour time.  (This gets stored in GSettings at /org/gnome/desktop/interface/clock-format.) Unfortunately gnome-calendar seems to ignore this setting: it always displays 12-hour time in the Week view, and always displays 24-hour time in the Event Details dialog.
Comment 1 Dmitri Smirnov 2016-02-08 19:00:15 UTC
Also, gnome-calendar ignores locale settings LC_TIME= and uses LANG= variable instead.
Comment 2 sadath.anwar17 2016-03-05 11:21:42 UTC
Created attachment 323145 [details] [review]
Respecting gnome's 12/24 hour format.
Comment 3 Georges Basile Stavracas Neto 2016-03-06 21:35:10 UTC
Review of attachment 323145 [details] [review]:

This patch is conceptually wrong. First, because we already set the format the 24h format by reading the settings (check gcal_time_selector_set_time_format() usage). Second, it has no commit message. Finally, see the comments below to help you learn a little bit more abot memory management cases.

::: src/gcal-time-selector.c
@@ +239,3 @@
+  gchar *clock_format;
+
+  settings = g_settings_new("org.gnome.desktop.interface");

Memleak: unref the settings after using it.

@@ +240,3 @@
+
+  settings = g_settings_new("org.gnome.desktop.interface");
+  clock_format = g_settings_get_string(settings,"clock-format");

Memleak: free the string after using it.
Comment 4 sadath.anwar17 2016-03-07 06:13:29 UTC
gcal_time_selector_set_time_format() doesnt work, it always sets the format to 24h irrespective of desktop format because i think we initialise it to 24h format in gcal_time_selector_init().
Comment 5 sadath.anwar17 2016-03-14 16:21:52 UTC
Created attachment 323895 [details] [review]
Edit dialog: Respecting GNOME's 12/24 hour format

The edit dialog time picker didnt take into account GNOME's hour format

The edit dialog time picker didnt take into account GNOME's hour format because the desktop settings clock-format from gcal-window was not passed to gcal-edit-dialog.

Now the data is passed to gcal-edit-dialog through a function gcal_edit_dialog_time_format and everything works fine as expected.
Comment 6 Georges Basile Stavracas Neto 2016-03-14 19:04:09 UTC
Review of attachment 323895 [details] [review]:

Needs some work yet.

::: src/gcal-edit-dialog.c
@@ +556,3 @@
 void
+gcal_edit_dialog_set_time_format (GcalEditDialog *dialog,
+                                  gboolean use_24h_format)

Fix the alignment.

@@ +558,3 @@
+                                  gboolean use_24h_format)
+{
+  dialog->format_24h = use_24h_format;

1. Check g_return_if_fail ()
2. Check if dialog->format_24h != use_24h_format.

::: src/gcal-edit-dialog.h
@@ +50,3 @@
 
+void                 gcal_edit_dialog_set_time_format         (GcalEditDialog *dialog,
+                                                               gboolean use_24h_format);

Fix the alignment.

::: src/gcal-time-selector.c
@@ -242,3 @@
-  clock_format = g_settings_get_string(settings,"clock-format");
-
-  self->format_24h = (g_strcmp0(clock_format,"24h") == 0);

This seems to be a diff from a previous commit of yours that is not present in git master. Thus, this patch does not apply. Remove this and I think it'll be fine.

::: src/gcal-window.c
@@ +1352,3 @@
   window->views[GCAL_WINDOW_VIEW_YEAR] = window->year_view;
 
+  gcal_edit_dialog_set_time_format (GCAL_EDIT_DIALOG (window->edit_dialog),use_24h_format);

Space after ','
Comment 7 sadath.anwar17 2016-03-14 20:08:59 UTC
Created attachment 323917 [details] [review]
Edit dialog: Respecting GNOME's 12/24 hour format

The edit dialog time picker didnt take into account GNOME's hour format.

The edit dialog time picker didnt take into account GNOME's hour format because the desktop settings clock-format from gcal-window was not passed to gcal-edit-dialog.

Now the data is passed to gcal-edit-dialog through a function gcal_edit_dialog_time_format and everything works fine as required.
Comment 8 Georges Basile Stavracas Neto 2016-03-14 20:17:58 UTC
Review of attachment 323917 [details] [review]:

Only a minor nitpick.

::: src/gcal-edit-dialog.c
@@ +552,3 @@
   dialog = g_object_new (GCAL_TYPE_EDIT_DIALOG, NULL);
 
+  return GTK_WIDGET (dialog);

Due to the code removal, you can simply "return g_object_new (GCAL_TYPE_EDIT_DIALOG, NULL);" here.
Comment 9 sadath.anwar17 2016-03-14 20:34:25 UTC
Created attachment 323920 [details] [review]
Edit dialog: Respecting GNOME's 12/24 hour format

The edit dialog time picker didnt take into account GNOME's hour format.

The edit dialog time picker didnt take into account GNOME's hour format because the desktop settings clock-format from gcal-window was not passed to gcal-edit-dialog.

Now the data is passed through the function gcal_edit_dialog_time_format and everything works as required.
Comment 10 Georges Basile Stavracas Neto 2016-03-14 20:43:03 UTC
Thanks for working on this issue.