OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
introduce a helper method for rendering the user's time zone
ulfertsb8409906927e
diff --git a/lib_static/redmine/i18n.rb b/lib_static/redmine/i18n.rbindex c54f18d32d9..6604ba31fc6 100644--- a/lib_static/redmine/i18n.rb+++ b/lib_static/redmine/i18n.rb@@ -147,6 +147,10 @@ module Redmine(Setting.time_format.blank? ? ::I18n.l(local, format: :time) : local.strftime(Setting.time_format))end+ def format_time_zone+ (User.current.time_zone || Time.zone).to_s[/\((.*?)\)/m, 1]+ end+def day_name(day)::I18n.t("date.day_names")[day % 7]enddiff --git a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb b/modules/meeting/app/components/meetings/side_panel/details_component.html.erbindex a49740fe66e..b7425f44e1a 100644--- a/modules/meeting/app/components/meetings/side_panel/details_component.html.erb+++ b/modules/meeting/app/components/meetings/side_panel/details_component.html.erb@@ -36,7 +36,7 @@time.with_column(ml: 2) dorender(Primer::Beta::Text.new(color: :subtle, font_size: :small)) do- (User.current.time_zone || Time.zone).to_s[/\((.*?)\)/m, 1]+ format_time_zoneendendenddiff --git a/modules/meeting/app/forms/meeting/start_time.rb b/modules/meeting/app/forms/meeting/start_time.rbindex d077e40230f..15fbf9e9649 100644--- a/modules/meeting/app/forms/meeting/start_time.rb+++ b/modules/meeting/app/forms/meeting/start_time.rb@@ -27,6 +27,8 @@#++class Meeting::StartTime < ApplicationForm+ include Redmine::I18n+form do |meeting_form|meeting_form.text_field(name: :start_time_hour,@@ -36,7 +38,7 @@ class Meeting::StartTime < ApplicationFormlabel: Meeting.human_attribute_name(:start_time),leading_visual: { icon: :clock },required: true,- caption: Time.zone.to_s[/\((.*?)\)/m, 1]+ caption: format_time_zone)enddiff --git a/spec/lib/redmine/i18n_spec.rb b/spec/lib/redmine/i18n_spec.rbindex e51c7d5b9f8..384a08475f3 100644--- a/spec/lib/redmine/i18n_spec.rb+++ b/spec/lib/redmine/i18n_spec.rb@@ -374,6 +374,48 @@ module OpenProjectendend+ describe "#format_time_zone" do+ current_user { build_stubbed(:user, preferences: { time_zone: user_time_zone }) }+ let(:user_time_zone) { "" }++ context "with the current user having set a time zone" do+ let(:user_time_zone) { "Kathmandu" }++ it "renders the time zone of the user" do+ # No DST in this time zone so the expectation should be constant.+ expect(format_time_zone).to eql "GMT+05:45"+ end+ end++ context "without the current user having a time zone and no default one configured" do+ let(:user_time_zone) { "" }++ it "renders the UTC time zone" do+ expect(format_time_zone).to eql "GMT+00:00"+ end+ end++ context "without the current user having a time zone but with a default one configured",+ with_settings: { user_default_timezone: "Kathmandu" } do+ let(:user_time_zone) { "" }++ it "renders the default time zone" do+ # No DST in this time zone so the expectation should be constant.+ expect(format_time_zone).to eql "GMT+05:45"+ end+ end++ context "without the current user having a time zone and also a default one configured",+ with_settings: { user_default_timezone: "Atlanta" } do+ let(:user_time_zone) { "Kathmandu" }++ it "renders the default time zone" do+ # No DST in this time zone so the expectation should be constant.+ expect(format_time_zone).to eql "GMT+05:45"+ end+ end+ end+describe "day names" dovalid_languages.each do |lang|context "for locale #{lang}" do