diff --git a/app/assets/javascripts/discourse/app/components/user-card-contents.js b/app/assets/javascripts/discourse/app/components/user-card-contents.js index 655c97fc28c..2feb813dacf 100644 --- a/app/assets/javascripts/discourse/app/components/user-card-contents.js +++ b/app/assets/javascripts/discourse/app/components/user-card-contents.js @@ -38,7 +38,12 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, { showMoreBadges: gt("moreBadgesCount", 0), showDelete: and("viewingAdmin", "showName", "user.canBeDeleted"), linkWebsite: not("user.isBasic"), - hasLocationOrWebsite: or("user.location", "user.website_name"), + + @discourseComputed("user") + hasLocaleOrWebsite(user) { + return user.location || user.website_name || this.userTimezone; + }, + isSuspendedOrHasBio: or("user.suspend_reason", "user.bio_excerpt"), showCheckEmail: and("user.staged", "canCheckEmails"), @@ -52,6 +57,8 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, { "siteSettings.allow_featured_topic_on_user_profiles" ), + showUserLocalTime: setting("display_local_time_in_user_card"), + @discourseComputed("user.staff") staff: isStaff => (isStaff ? "staff" : ""), @@ -63,6 +70,17 @@ export default Component.extend(CardContentsBase, CanCheckEmails, CleansUp, { return prioritizeNameInUx(name, this.siteSettings); }, + @discourseComputed("user") + userTimezone(user) { + return user.resolvedTimezone(); + }, + + @discourseComputed() + formattedUserLocalTime() { + const timezone = this.userTimezone; + return moment.tz(timezone).format(I18n.t("dates.time_with_zone")); + }, + @discourseComputed("username") usernameClass: username => (username ? `user-card-${username}` : ""), diff --git a/app/assets/javascripts/discourse/app/models/user.js b/app/assets/javascripts/discourse/app/models/user.js index 9fff14f4f87..dc118c08926 100644 --- a/app/assets/javascripts/discourse/app/models/user.js +++ b/app/assets/javascripts/discourse/app/models/user.js @@ -597,6 +597,11 @@ const User = RestModel.extend({ json.user.card_badge = Badge.create(json.user.card_badge); } + if (!json.user._timezone) { + json.user._timezone = json.user.timezone; + delete json.user.timezone; + } + user.setProperties(json.user); return user; }); diff --git a/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs b/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs index 3be60e856cb..3148fc95d33 100644 --- a/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs +++ b/app/assets/javascripts/discourse/app/templates/components/user-card-contents.hbs @@ -149,15 +149,9 @@ {{/if}} - {{#if this.hasLocationOrWebsite}} + {{#if this.hasLocaleOrWebsite}}
- {{#if this.user.location}} - - {{d-icon "map-marker-alt"}} - {{this.user.location}} - - {{/if}} {{#if this.user.website_name}} {{d-icon "globe"}} @@ -170,6 +164,18 @@ {{/if}} {{/if}} + {{#if this.user.location}} + + {{d-icon "map-marker-alt"}} + {{this.user.location}} + + {{/if}} + {{#if showUserLocalTime}} + + {{d-icon "far-clock"}} + {{this.formattedUserLocalTime}} + + {{/if}} {{plugin-outlet name="user-card-location-and-website" args=(hash user=this.user)}}
diff --git a/app/assets/stylesheets/common/components/user-card.scss b/app/assets/stylesheets/common/components/user-card.scss index c5dad5d0896..92ca3a5af08 100644 --- a/app/assets/stylesheets/common/components/user-card.scss +++ b/app/assets/stylesheets/common/components/user-card.scss @@ -212,7 +212,9 @@ $avatar_margin: -50px; // negative margin makes avatars extend above cards @include ellipsis; color: $primary; } - .location { + .location, + .local-time, + .website-name { margin-right: 0.5em; } .website-name a { diff --git a/app/serializers/user_card_serializer.rb b/app/serializers/user_card_serializer.rb index 6b7f59cd40d..c453dff2e4d 100644 --- a/app/serializers/user_card_serializer.rb +++ b/app/serializers/user_card_serializer.rb @@ -60,7 +60,8 @@ class UserCardSerializer < BasicUserSerializer :primary_group_flair_url, :primary_group_flair_bg_color, :primary_group_flair_color, - :featured_topic + :featured_topic, + :timezone untrusted_attributes :bio_excerpt, :website, @@ -194,6 +195,14 @@ class UserCardSerializer < BasicUserSerializer object.user_profile.featured_topic end + def include_timezone? + SiteSetting.display_local_time_in_user_card? + end + + def timezone + object.user_option.timezone + end + def card_background_upload_url object.card_background_upload&.url end diff --git a/config/locales/client.ar.yml b/config/locales/client.ar.yml index d2551f34b91..dd741999117 100644 --- a/config/locales/client.ar.yml +++ b/config/locales/client.ar.yml @@ -31,6 +31,7 @@ ar: millions: "{{number}} مليون" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" diff --git a/config/locales/client.be.yml b/config/locales/client.be.yml index c9c33e11177..67247aea1a3 100644 --- a/config/locales/client.be.yml +++ b/config/locales/client.be.yml @@ -25,6 +25,7 @@ be: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" long_no_year_no_time: "D MMM" long_with_year_no_time: "D МММ, YYYY" long_date_with_year_without_time: "D MMM YYYY" diff --git a/config/locales/client.bg.yml b/config/locales/client.bg.yml index 298f6fc63d0..addc3fdbacd 100644 --- a/config/locales/client.bg.yml +++ b/config/locales/client.bg.yml @@ -27,6 +27,7 @@ bg: millions: "{{number}}M " dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" diff --git a/config/locales/client.bs_BA.yml b/config/locales/client.bs_BA.yml index e99e72dc0f9..93e103c9935 100644 --- a/config/locales/client.bs_BA.yml +++ b/config/locales/client.bs_BA.yml @@ -28,6 +28,7 @@ bs_BA: millions: "{{number}} miliona" dates: time: "HH: mm" + time_with_zone: "HH: mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.ca.yml b/config/locales/client.ca.yml index d3c05e308f7..80f47fb2dfb 100644 --- a/config/locales/client.ca.yml +++ b/config/locales/client.ca.yml @@ -27,6 +27,7 @@ ca: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.cs.yml b/config/locales/client.cs.yml index 84c4b405fd8..1faece6fa45 100644 --- a/config/locales/client.cs.yml +++ b/config/locales/client.cs.yml @@ -29,6 +29,7 @@ cs: millions: "{{number}}M" dates: time: "H:mm" + time_with_zone: "H:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "D. MMMM" full_no_year_no_time: "D. MMMM" diff --git a/config/locales/client.da.yml b/config/locales/client.da.yml index cfb52a677ae..c75122c70bb 100644 --- a/config/locales/client.da.yml +++ b/config/locales/client.da.yml @@ -27,6 +27,7 @@ da: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "D. MMM" full_no_year_no_time: "D. MMMM" diff --git a/config/locales/client.de.yml b/config/locales/client.de.yml index 9cc356de431..64e90d534fc 100644 --- a/config/locales/client.de.yml +++ b/config/locales/client.de.yml @@ -27,6 +27,7 @@ de: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D. MMM" diff --git a/config/locales/client.el.yml b/config/locales/client.el.yml index 0dbe63981f8..94d50da9924 100644 --- a/config/locales/client.el.yml +++ b/config/locales/client.el.yml @@ -27,6 +27,7 @@ el: millions: "{{number}}εκατ." dates: time: "ΗΗ:mm" + time_with_zone: "HH:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "DD MMM" full_no_year_no_time: "Do MMMM" diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index af4c1549b1d..3180d66d2fa 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -40,6 +40,8 @@ en: # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ time: "HH:mm" # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ + time_with_zone: "HH:mm (z)" + # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ time_short_day: "ddd, HH:mm" # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ timeline_date: "MMM YYYY" diff --git a/config/locales/client.en_US.yml b/config/locales/client.en_US.yml index 96cf5c211d7..889e8c66c92 100644 --- a/config/locales/client.en_US.yml +++ b/config/locales/client.en_US.yml @@ -4,6 +4,8 @@ en_US: # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ time: "h:mm a" # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ + time_with_zone: "hh:mm a (z)" + # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ time_short_day: "ddd, h:mm a" # Use Moment.js format string: https://momentjs.com/docs/#/displaying/format/ timeline_date: "MMM YYYY" diff --git a/config/locales/client.es.yml b/config/locales/client.es.yml index f9649f57257..63ebcf23f57 100644 --- a/config/locales/client.es.yml +++ b/config/locales/client.es.yml @@ -27,6 +27,7 @@ es: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year: "D MMM, HH:mm" diff --git a/config/locales/client.et.yml b/config/locales/client.et.yml index 8c185b0f9d8..cf67e2d4aa5 100644 --- a/config/locales/client.et.yml +++ b/config/locales/client.et.yml @@ -27,6 +27,7 @@ et: millions: "{{number}}M" dates: time: "hh:mm" + time_with_zone: "hh:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "D. MMMM" full_no_year_no_time: "Do MMMM" diff --git a/config/locales/client.fa_IR.yml b/config/locales/client.fa_IR.yml index 57efc8e0419..3e3d664341d 100644 --- a/config/locales/client.fa_IR.yml +++ b/config/locales/client.fa_IR.yml @@ -27,6 +27,7 @@ fa_IR: millions: "{{number}} میلیون" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" diff --git a/config/locales/client.fi.yml b/config/locales/client.fi.yml index 0f5e360629f..a66782aa500 100644 --- a/config/locales/client.fi.yml +++ b/config/locales/client.fi.yml @@ -27,6 +27,7 @@ fi: millions: "{{number}}M" dates: time: "H:mm" + time_with_zone: "H:mm (z)" time_short_day: "ddd HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D. MMMM[ta]" diff --git a/config/locales/client.fr.yml b/config/locales/client.fr.yml index db522c2b260..2a764de244c 100644 --- a/config/locales/client.fr.yml +++ b/config/locales/client.fr.yml @@ -27,6 +27,7 @@ fr: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd [à] HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" diff --git a/config/locales/client.gl.yml b/config/locales/client.gl.yml index 1e6bb87c66f..8a8624aba34 100644 --- a/config/locales/client.gl.yml +++ b/config/locales/client.gl.yml @@ -27,6 +27,7 @@ gl: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" full_no_year_no_time: "D MMMM" diff --git a/config/locales/client.he.yml b/config/locales/client.he.yml index 450b1167eaa..cd388cc3823 100644 --- a/config/locales/client.he.yml +++ b/config/locales/client.he.yml @@ -29,6 +29,7 @@ he: millions: "{{number}} מיליון" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year: "D MMM, HH:mm" diff --git a/config/locales/client.hu.yml b/config/locales/client.hu.yml index f843aad5c88..6500e02233a 100644 --- a/config/locales/client.hu.yml +++ b/config/locales/client.hu.yml @@ -27,6 +27,7 @@ hu: millions: "{{number}} millió" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" timeline_date: "YYYY MMMM" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMM DD" diff --git a/config/locales/client.hy.yml b/config/locales/client.hy.yml index b446663a916..b5e6fa470c4 100644 --- a/config/locales/client.hy.yml +++ b/config/locales/client.hy.yml @@ -27,6 +27,7 @@ hy: millions: "{{number}}մլն" dates: time: "h:mm" + time_with_zone: "h:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.id.yml b/config/locales/client.id.yml index 410f902df71..21b6f48c6e9 100644 --- a/config/locales/client.id.yml +++ b/config/locales/client.id.yml @@ -26,6 +26,7 @@ id: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" time_short_day: "ddd, HH: mm" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" diff --git a/config/locales/client.it.yml b/config/locales/client.it.yml index ac69f908f37..b3232e2d8c5 100644 --- a/config/locales/client.it.yml +++ b/config/locales/client.it.yml @@ -27,6 +27,7 @@ it: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year: "D MMM, HH:mm" diff --git a/config/locales/client.ja.yml b/config/locales/client.ja.yml index 59291ac65d9..4fb8795c6b4 100644 --- a/config/locales/client.ja.yml +++ b/config/locales/client.ja.yml @@ -26,6 +26,7 @@ ja: millions: "{{number}}M" dates: time: "H:mm" + time_with_zone: "H:mm (z)" timeline_date: "YYYY年M月" long_no_year_no_time: "M月D日" full_no_year_no_time: "M月D日" diff --git a/config/locales/client.ko.yml b/config/locales/client.ko.yml index 9e2ede793b9..22cdf967c51 100644 --- a/config/locales/client.ko.yml +++ b/config/locales/client.ko.yml @@ -26,6 +26,7 @@ ko: millions: "{{number}}백만" dates: time: "a h:mm" + time_with_zone: "a h:mm (z)" timeline_date: "YYYY MMM" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.lt.yml b/config/locales/client.lt.yml index fc7f0bc130d..c04e5b9d4ef 100644 --- a/config/locales/client.lt.yml +++ b/config/locales/client.lt.yml @@ -29,6 +29,7 @@ lt: millions: "{{number}}M" dates: time: "H:mm" + time_with_zone: "H:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.lv.yml b/config/locales/client.lv.yml index 2552f541c3c..5e021880d6b 100644 --- a/config/locales/client.lv.yml +++ b/config/locales/client.lv.yml @@ -28,6 +28,7 @@ lv: millions: "{{number}} milj." dates: time: "hh:mm" + time_with_zone: "hh:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.nb_NO.yml b/config/locales/client.nb_NO.yml index 62b0e76a053..9782c2233eb 100644 --- a/config/locales/client.nb_NO.yml +++ b/config/locales/client.nb_NO.yml @@ -27,6 +27,7 @@ nb_NO: millions: "{{number}}M" dates: time: "LT" + time_with_zone: "LT (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" full_no_year_no_time: "D. MMMM" diff --git a/config/locales/client.nl.yml b/config/locales/client.nl.yml index 27240c9afc5..e69cca0469d 100644 --- a/config/locales/client.nl.yml +++ b/config/locales/client.nl.yml @@ -27,6 +27,7 @@ nl: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year: "D MMM, HH:mm" diff --git a/config/locales/client.pl_PL.yml b/config/locales/client.pl_PL.yml index f558984e7a3..2db63526d8f 100644 --- a/config/locales/client.pl_PL.yml +++ b/config/locales/client.pl_PL.yml @@ -29,6 +29,7 @@ pl_PL: millions: "{{number}}M" dates: time: "H:mm" + time_with_zone: "H:mm (z)" time_short_day: "ddd, GG: mm" timeline_date: "MMM YYYY" long_no_year: "D MMM, GG: mm" diff --git a/config/locales/client.pt.yml b/config/locales/client.pt.yml index 29bedc2d68b..67fcbe27a9c 100644 --- a/config/locales/client.pt.yml +++ b/config/locales/client.pt.yml @@ -27,6 +27,7 @@ pt: millions: "{{number}}M" dates: time: "hh:mm" + time_with_zone: "hh:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "DD MMM" full_no_year_no_time: "Do MMMM" diff --git a/config/locales/client.pt_BR.yml b/config/locales/client.pt_BR.yml index d95190318de..bf673507c17 100644 --- a/config/locales/client.pt_BR.yml +++ b/config/locales/client.pt_BR.yml @@ -27,6 +27,7 @@ pt_BR: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" diff --git a/config/locales/client.ro.yml b/config/locales/client.ro.yml index a26fed9e101..51d21ec82bc 100644 --- a/config/locales/client.ro.yml +++ b/config/locales/client.ro.yml @@ -28,6 +28,7 @@ ro: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "DD MMM" full_no_year_no_time: "Do MMMM " diff --git a/config/locales/client.ru.yml b/config/locales/client.ru.yml index 20eac7a0e7b..540448bc356 100644 --- a/config/locales/client.ru.yml +++ b/config/locales/client.ru.yml @@ -29,6 +29,7 @@ ru: millions: "{{number}} млн." dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year: "D MMM, HH:mm" diff --git a/config/locales/client.sk.yml b/config/locales/client.sk.yml index 4c9a45d361f..2fec5c9696c 100644 --- a/config/locales/client.sk.yml +++ b/config/locales/client.sk.yml @@ -29,6 +29,7 @@ sk: millions: "{{number}}mil" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.sl.yml b/config/locales/client.sl.yml index 2cd21fe1996..4f707df6d05 100644 --- a/config/locales/client.sl.yml +++ b/config/locales/client.sl.yml @@ -29,6 +29,7 @@ sl: millions: "{{number}}M" dates: time: "H:mm" + time_with_zone: "H:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" full_no_year_no_time: "D. MMMM" diff --git a/config/locales/client.sq.yml b/config/locales/client.sq.yml index 71a48fb4154..f4e4997c20c 100644 --- a/config/locales/client.sq.yml +++ b/config/locales/client.sq.yml @@ -27,6 +27,7 @@ sq: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.sr.yml b/config/locales/client.sr.yml index c5dc6248f47..ddf56cf62c2 100644 --- a/config/locales/client.sr.yml +++ b/config/locales/client.sr.yml @@ -28,6 +28,7 @@ sr: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.sv.yml b/config/locales/client.sv.yml index 0b8e573f90f..0a5078294b6 100644 --- a/config/locales/client.sv.yml +++ b/config/locales/client.sv.yml @@ -27,6 +27,7 @@ sv: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year: "D MMM, HH:mm" diff --git a/config/locales/client.sw.yml b/config/locales/client.sw.yml index 02798902544..3bab45669cd 100644 --- a/config/locales/client.sw.yml +++ b/config/locales/client.sw.yml @@ -27,6 +27,7 @@ sw: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.te.yml b/config/locales/client.te.yml index ff17c45be29..a6e245faf52 100644 --- a/config/locales/client.te.yml +++ b/config/locales/client.te.yml @@ -24,6 +24,7 @@ te: tb: టీబీ dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" long_no_year_no_time: "MMM D" long_with_year: "MMM D, YYYY h:mm a" long_with_year_no_time: "MMM D, YYYY" diff --git a/config/locales/client.th.yml b/config/locales/client.th.yml index 273bcc27c80..a9c73f525d3 100644 --- a/config/locales/client.th.yml +++ b/config/locales/client.th.yml @@ -26,6 +26,7 @@ th: millions: "{{number}}ล้าน" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.tr_TR.yml b/config/locales/client.tr_TR.yml index e0554c02f3a..066a38b3399 100644 --- a/config/locales/client.tr_TR.yml +++ b/config/locales/client.tr_TR.yml @@ -27,6 +27,7 @@ tr_TR: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" time_short_day: "ggg, SS:dd" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" diff --git a/config/locales/client.uk.yml b/config/locales/client.uk.yml index 10fdd74b48f..6930870cf42 100644 --- a/config/locales/client.uk.yml +++ b/config/locales/client.uk.yml @@ -29,6 +29,7 @@ uk: millions: "{{number}} млн." dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" diff --git a/config/locales/client.ur.yml b/config/locales/client.ur.yml index b99357bb5ac..fe817015db4 100644 --- a/config/locales/client.ur.yml +++ b/config/locales/client.ur.yml @@ -27,6 +27,7 @@ ur: millions: "{{number}}M" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" timeline_date: "MMM YYYY" long_no_year_no_time: "MMM D" full_no_year_no_time: "MMMM Do" diff --git a/config/locales/client.vi.yml b/config/locales/client.vi.yml index 616c335137c..7ddbc480557 100644 --- a/config/locales/client.vi.yml +++ b/config/locales/client.vi.yml @@ -26,6 +26,7 @@ vi: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "MMM YYYY" long_no_year_no_time: "D MMM" diff --git a/config/locales/client.zh_CN.yml b/config/locales/client.zh_CN.yml index 6a301be0782..b54822a862e 100644 --- a/config/locales/client.zh_CN.yml +++ b/config/locales/client.zh_CN.yml @@ -26,6 +26,7 @@ zh_CN: millions: "{{number}}M" dates: time: "HH:mm" + time_with_zone: "HH:mm (z)" time_short_day: "ddd, HH:mm" timeline_date: "YYYY[年]M[月]" long_no_year: "M[月]D[日] HH:mm" diff --git a/config/locales/client.zh_TW.yml b/config/locales/client.zh_TW.yml index bb5ef5ed456..1d5b3ce010b 100644 --- a/config/locales/client.zh_TW.yml +++ b/config/locales/client.zh_TW.yml @@ -26,6 +26,7 @@ zh_TW: millions: "{{number}} 百萬" dates: time: "h:mm a" + time_with_zone: "h:mm a (z)" timeline_date: "YYYY年 M月" long_no_year_no_time: "M月 D日" full_no_year_no_time: "M月 D日" diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d38b0caeab9..baf137f94bb 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1407,6 +1407,7 @@ en: watched_word_regexp_error: "The regular expression for %{action} watched words is invalid. Please check your Watched Word settings, or disable the 'watched words regular expressions' site setting." site_settings: + display_local_time_in_user_card: "Display the local time based on a user's timezone when their user card is opened." censored_words: "Words that will be automatically replaced with ■■■■" delete_old_hidden_posts: "Auto-delete any hidden posts that stay hidden for more than 30 days." default_locale: "The default language of this Discourse instance. You can replace the text of system generated categories and topics at Customize / Text." diff --git a/config/site_settings.yml b/config/site_settings.yml index 8037237c2a7..7d9fd0fd869 100644 --- a/config/site_settings.yml +++ b/config/site_settings.yml @@ -124,6 +124,9 @@ branding: default: "" basic: + display_local_time_in_user_card: + client: true + default: false allow_user_locale: client: true default: false diff --git a/test/javascripts/acceptance/user-card-test.js b/test/javascripts/acceptance/user-card-test.js index 8ced970f99c..ecf98706124 100644 --- a/test/javascripts/acceptance/user-card-test.js +++ b/test/javascripts/acceptance/user-card-test.js @@ -1,6 +1,46 @@ import { acceptance } from "helpers/qunit-helpers"; import DiscourseURL from "discourse/lib/url"; +import pretender from "helpers/create-pretender"; +import userFixtures from "fixtures/user_fixtures"; +import User from "discourse/models/user"; + +acceptance("User Card - Show Local Time", { + loggedIn: true, + settings: { display_local_time_in_user_card: true } +}); + +QUnit.test("user card local time", async assert => { + User.current().changeTimezone("Australia/Brisbane"); + let cardResponse = _.clone(userFixtures["/u/eviltrout/card.json"]); + cardResponse.user.timezone = "Australia/Perth"; + + pretender.get("/u/eviltrout/card.json", () => [ + 200, + { "Content-Type": "application/json" }, + cardResponse + ]); + + await visit("/t/internationalization-localization/280"); + assert.ok(invisible(".user-card"), "user card is invisible by default"); + await click("a[data-user-card=eviltrout]:first"); + + let expectedTime = + moment + .tz("Australia/Brisbane") + .add(-2, "hours") + .format("hh:mm a") + " (AWST)"; + + assert.ok(visible(".user-card"), "card should appear"); + assert.equal( + find(".user-card .local-time") + .text() + .trim(), + expectedTime, + "user card contains the user's local time" + ); +}); + acceptance("User Card", { loggedIn: true }); QUnit.test("user card", async assert => { @@ -34,6 +74,11 @@ QUnit.test("user card", async assert => { "user card contains the data" ); + assert.ok( + !visible(".user-card .local-time"), + "local time with zone does not show by default" + ); + await click(".card-content .compose-pm button"); assert.ok( invisible(".user-card"),