UX: emphasizes on local-dates being UTC in excerpts (#8208)

UX: emphasizes on local-dates being UTC in excerpts (#8208)

diff --git a/plugins/discourse-local-dates/plugin.rb b/plugins/discourse-local-dates/plugin.rb
index 2adf23dca0..5ee9fefad7 100644
--- a/plugins/discourse-local-dates/plugin.rb
+++ b/plugins/discourse-local-dates/plugin.rb
@@ -53,6 +53,12 @@ after_initialize do
     custom_fields[DiscourseLocalDates::POST_CUSTOM_FIELD] || []
   end
 
+  on(:reduce_excerpt) do |fragment, post|
+    fragment.css('.discourse-local-date').each do |container|
+      container.content = "#{container.content} (UTC)"
+    end
+  end
+
   on(:reduce_cooked) do |fragment|
     fragment.css('.discourse-local-date').each do |container|
       if container.attributes['data-email-preview']
diff --git a/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb b/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb
index 476dd54f3d..6a1a4ec76f 100644
--- a/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb
+++ b/plugins/discourse-local-dates/spec/lib/pretty_text_spec.rb
@@ -71,4 +71,13 @@ describe PrettyText do
       end
     end
   end
+
+  context 'excerpt simplified rendering' do
+    let(:post) { Fabricate(:post, raw: '[date=2019-10-16 time=14:00:00 format="LLLL" timezone="America/New_York"]') }
+
+    it 'adds UTC' do
+      excerpt = PrettyText.excerpt(post.cooked, 200)
+      expect(excerpt).to eq("Wednesday, October 16, 2019 6:00 PM (UTC)")
+    end
+  end
 end

GitHub sha: 54bc2bdb

1 Like