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 520226 - clock: sunset/sunrise do not honor 12 hour format setting
clock: sunset/sunrise do not honor 12 hour format setting
Status: RESOLVED FIXED
Product: gnome-panel
Classification: Other
Component: clock
2.21.x
Other Linux
: Normal trivial
: ---
Assigned To: Panel Maintainers
Panel Maintainers
: 557643 (view as bug list)
Depends on: 520176
Blocks:
 
 
Reported: 2008-03-04 02:35 UTC by Wade Menard
Modified: 2010-02-09 21:22 UTC
See Also:
GNOME target: ---
GNOME version: 2.21/2.22


Attachments
example of sunset in 24 hour format (12.40 KB, image/png)
2008-03-04 02:35 UTC, Wade Menard
  Details
Sunrise/Sunset time uses 12h/24h preference (4.29 KB, patch)
2009-06-25 14:02 UTC, Ted M Lin
none Details | Review
Sunrise/Sunset time uses 12h/24h preference (revised) (5.30 KB, patch)
2009-09-02 02:08 UTC, Ted M Lin
accepted-commit_now Details | Review

Description Wade Menard 2008-03-04 02:35:26 UTC
When enabling weather and pointing at the temperature, the tooltip shows Sunrise/Sunset. However the sunset does not respect the "12 hour format/24 hour format" setting of the applet and shows it as something like "Sunset: 18:27"

Expected: the applet should translate the Sunrise/Sunset to 12 hour format (6:27 PM) if that is how the applet is configured.
Comment 1 Wade Menard 2008-03-04 02:35:58 UTC
Created attachment 106525 [details]
example of sunset in 24 hour format
Comment 2 Wade Menard 2008-03-04 02:56:14 UTC
I poked at clock-location-tile.c and saw this comment at the Sunrise/Setset presentation code written by Vincent Untz:

/* FIXME: we need libgweather to give us the time,
 * not just a formatted string
 */

Doh. So unless there it's acceptable to do some string parsing in this case it looks like properly fixing this bug depends on that FIXME.


Comment 3 Wade Menard 2008-03-04 03:01:43 UTC
Fair to depends on: bug #520176 ?
Comment 4 Pavel Šefránek 2008-04-26 21:48:15 UTC
Mayber related to bug 529991
Comment 5 Michael Miceli 2008-08-20 22:11:34 UTC
Depends on libgweather returning different values.  Discussed in Bug#538787 [[http://bugzilla.gnome.org/show_bug.cgi?id=538787]]  Once this is committed and ironed out.  Fixing this shouldn't be bad at all.
Comment 6 Vincent Untz 2009-01-08 14:36:12 UTC
*** Bug 557643 has been marked as a duplicate of this bug. ***
Comment 7 Philippe Chaintreuil 2009-01-16 16:22:22 UTC
Footnote: it would be nice if the gweather applet would also resepect the date formatting when it displays the Sunrise & Sunset fields.  But I'm guessing that also depends on #518787 + gweather being able to get at the preferred date/time formating from clock....
Comment 8 Ted M Lin 2009-06-25 14:02:43 UTC
Created attachment 137365 [details] [review]
Sunrise/Sunset time uses 12h/24h preference

Here's a patch (made against gnome-panel 2.26.2-1ubunutu1; ref LP: #197657).
This code requires the value APIs introduced in libgweather 2.25.2.
Comment 9 Matthias Clasen 2009-08-10 21:26:21 UTC
Some small issues:

+	if (clock_format == CLOCK_FORMAT_12)
+		format = _("%l:%M %p");
+	else
+		format = _("%H:%M");
+

This needs at least a translator comment explaining that a) this is a strftime format string and b) what it is used for.

 	tzset ();
+	if (weather_info_get_value_sunrise (info, &sunrise_time))
+		sunrise_str = convert_time_to_str (sunrise_time, clock_format);
+	else
+		sunrise_str = g_strdup ("???");

I don't think "???" is something we ever want to display. If we can't get a valid string, just don't show the time.
Comment 10 Ted M Lin 2009-09-01 18:35:08 UTC
Thanks for the comments.

Re: translator comment; that's correct... that should have been added.  The same format strings also exist in (clock.c) without translation comment, which should also be commented.

Re: "???" text; the source file (clock-location-tile.c) already has a few instances of placing "???" into the output when there is an invalid string.  The new code I added duplicated similar logic, so I kept the same semantics of display.

If people like, I will submit a new patch with these changes.
Comment 11 Ted M Lin 2009-09-02 02:08:23 UTC
Created attachment 142294 [details] [review]
Sunrise/Sunset time uses 12h/24h preference (revised)

This updated patch adds translation notes for the strftime format strings.

The "???" unknown time strings have been left, since much of the pre-existing code uses this for unknown time.  Some discussion by the main developers should probably be done to fix it over the entire 'clock' codebase.
Comment 12 Philippe Chaintreuil 2009-11-03 18:48:07 UTC
Has Ted's patch been accepted?
Comment 13 Matthias Clasen 2010-02-09 20:54:50 UTC
Patch looks good to me now. As already mentioned, the strings are already present in the clock, so it doesn't add new strings.

IMO, we should get this in. Vincent ?
Comment 14 Vincent Untz 2010-02-09 21:03:58 UTC
Review of attachment 142294 [details] [review]:

Please commit with the suggestions below.

::: applets/clock/clock-location-tile.c
@@ +505,3 @@
+convert_time_to_str (time_t now, ClockFormat clock_format)
+{
+	gchar *format;

const gchar *

@@ +522,3 @@
+ * for a 24-hour format.
+ * There should be little need to translate this string.
+ */

Please use the same translator comments as used in clock.c for the same strings.

@@ +636,3 @@
 	sys_timezone = getenv ("TZ");
 	setenv ("TZ", clock_location_get_timezone (location), 1);
 	tzset ();

Add empty line here.

@@ +648,3 @@
+				 sunrise_str, sunset_str);
+	g_free (sunrise_str);
+	g_free (sunset_str);

Add empty line after this.
Comment 15 Matthias Clasen 2010-02-09 21:22:01 UTC
Thanks, committed with those changes.