[geary: 6/8] composer: use locale-preferred time format when quoting



commit dcf821f97e3f68ccbf4e2ebfd7c3ff62d331bf14
Author: Konstantin Kharlamov <Hi-Angel yandex ru>
Date:   Sun Mar 10 02:59:57 2019 +0300

    composer: use locale-preferred time format when quoting
    
    Bugzilla: https://gitlab.gnome.org/GNOME/geary/issues/272
    
    Signed-off-by: Konstantin Kharlamov <Hi-Angel yandex ru>

 src/client/composer/composer-widget.vala |  7 ++++++-
 src/client/util/util-date.vala           | 19 +++++++++++++++++++
 src/client/util/util-email.vala          |  9 +++++----
 3 files changed, 30 insertions(+), 5 deletions(-)
---
diff --git a/src/client/composer/composer-widget.vala b/src/client/composer/composer-widget.vala
index 89298a4c..1b541395 100644
--- a/src/client/composer/composer-widget.vala
+++ b/src/client/composer/composer-widget.vala
@@ -777,6 +777,7 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
                 this.subject = reply_subject;
                 this.references = Geary.RFC822.Utils.reply_references(referred);
                 referred_quote = Util.Email.quote_email_for_reply(referred, quote,
+                    config.clock_format,
                     Geary.RFC822.TextFormat.HTML);
                 if (!Geary.String.is_empty(quote)) {
                     this.top_posting = false;
@@ -1011,7 +1012,11 @@ public class ComposerWidget : Gtk.EventBox, Geary.BaseInterface {
             this.last_quote = quote;
             // Always use reply styling, since forward styling doesn't work for inline quotes
             this.editor.insert_html(
-                Util.Email.quote_email_for_reply(referred, quote, Geary.RFC822.TextFormat.HTML)
+                Util.Email.quote_email_for_reply(referred,
+                                                 quote,
+                                                 config.clock_format,
+                                                 Geary.RFC822.TextFormat.HTML)
+
             );
 
             if (!referred_ids.contains(referred.id)) {
diff --git a/src/client/util/util-date.vala b/src/client/util/util-date.vala
index faf2c966..36a71c69 100644
--- a/src/client/util/util-date.vala
+++ b/src/client/util/util-date.vala
@@ -213,4 +213,23 @@ public string get_clock_format(ClockFormat clock_format) {
     return xlat_pretty_clocks[clock_format.to_index()];
 }
 
+public string get_full_date(ClockFormat clock_format) {
+    switch(clock_format) {
+        case ClockFormat.TWELVE_HOURS:
+            /// 12 hours format for datetime that a message being replied to was received
+            /// See http://developer.gnome.org/glib/2.32/glib-GDateTime.html#g-date-time-format
+            return _("%a, %b %-e, %Y at %l:%M %P");
+        case ClockFormat.TWENTY_FOUR_HOURS:
+            /// 24 hours format for the datetime that a message being replied to was received
+            /// See http://developer.gnome.org/glib/2.32/glib-GDateTime.html#g-date-time-format
+            return _("%a, %b %-e, %Y at %H:%M");
+        case ClockFormat.LOCALE_DEFAULT:
+            /// Format for the datetime that a message being replied to was received
+            /// See http://developer.gnome.org/glib/2.32/glib-GDateTime.html#g-date-time-format
+            return _("%a, %b %-e, %Y at %X");
+    }
+    GLib.assert(false); // unreachable
+    return "";
+}
+
 }
diff --git a/src/client/util/util-email.vala b/src/client/util/util-email.vala
index 755c7522..17b2bcb5 100644
--- a/src/client/util/util-email.vala
+++ b/src/client/util/util-email.vala
@@ -142,15 +142,16 @@ namespace Util.Email {
      * If html_format is true, the message will be quoted in HTML format.
      * Otherwise it will be in plain text.
      */
-    public string quote_email_for_reply(Geary.Email email, string? quote, Geary.RFC822.TextFormat format) {
+    public string quote_email_for_reply(Geary.Email email,
+                                        string? quote,
+                                        Util.Date.ClockFormat clock_format,
+                                        Geary.RFC822.TextFormat format) {
         if (email.body == null && quote == null)
             return "";
 
         string quoted = "";
 
-        /// Format for the datetime that a message being replied to was received
-        /// See http://developer.gnome.org/glib/2.32/glib-GDateTime.html#g-date-time-format
-        string DATE_FORMAT = _("%a, %b %-e, %Y at %-l:%M %p");
+        string DATE_FORMAT = Util.Date.get_full_date(clock_format);
 
         if (email.date != null && email.from != null) {
             /// The quoted header for a message being replied to.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]