[gnome-clocks] Repair time string when used with non UTF-8 locale
- From: Evgeny Bobkin <ebobkin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-clocks] Repair time string when used with non UTF-8 locale
- Date: Fri, 26 Jul 2013 10:41:34 +0000 (UTC)
commit f070971a2dabde8c431bbfc856b882b5db782fcc
Author: Evgeny Bobkin <evgen ibqn gmail com>
Date: Fri Jul 26 10:31:04 2013 +0200
Repair time string when used with non UTF-8 locale
https://bugzilla.gnome.org/show_bug.cgi?id=698942
src/utils.vala | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/src/utils.vala b/src/utils.vala
index 8a0eb90..6dbddd3 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -125,10 +125,18 @@ public class WallClock : Object {
}
public string format_time (GLib.DateTime date_time) {
- // Note that the format uses unicode RATIO ("∶" \xE2\x88\xB6 or "\u2236")
- // prepended by the LTR mark(\xE2\x80\x8E or "\u200E") and
- // THIN SPACE(\xE2\x80\x89 or "\u2009") characters
- return date_time.format (format == Format.TWELVE ? "%I\xE2\x80\x8E\xE2\x88\xB6%M\xE2\x80\x89%p" :
"%H\xE2\x80\x8E\xE2\x88\xB6%M");
+ string time = date_time.format (format == Format.TWELVE ? "%I:%M %p" : "%H:%M");
+
+ // Replace ":" with ratio, space with thin-space, and prepend LTR marker
+ // to force direction. Replacement is done afterward because date_time.format
+ // may fail with utf8 chars in some locales
+ time = time.replace (":", "\xE2\x80\x8E\xE2\x88\xB6");
+
+ if (format == Format.TWELVE) {
+ time = time.replace (" ", "\xE2\x80\x89");
+ }
+
+ return time;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]