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
remove local time reference from format_time_as_date
ulferts1373a1854525
diff --git a/lib_static/redmine/i18n.rb b/lib_static/redmine/i18n.rbindex 534884af36e..481c9d13527 100644--- a/lib_static/redmine/i18n.rb+++ b/lib_static/redmine/i18n.rb@@ -120,11 +120,7 @@ module Redminereturn nil unless timezone = User.current.time_zone- local_date = (if zone- time.in_time_zone(zone)- else- time.utc? ? time.localtime : time- end).to_date+ local_date = time.in_time_zone(zone).to_dateif formatlocal_date.strftime(format)diff --git a/spec/lib/redmine/i18n_spec.rb b/spec/lib/redmine/i18n_spec.rbindex 3c4ceaf4256..c122a363bf5 100644--- a/spec/lib/redmine/i18n_spec.rb+++ b/spec/lib/redmine/i18n_spec.rb@@ -36,43 +36,33 @@ module OpenProjectlet(:user) { build_stubbed(:user) }describe "#format_time_as_date" do+ current_user { build_stubbed(:user, preferences: { time_zone: user_time_zone }) }+describe "with user time zone" do- before do- login_as user- allow(user).to receive(:time_zone).and_return(ActiveSupport::TimeZone["Athens"])- end+ let(:user_time_zone) { "Europe/Athens" }it "returns a date in the user timezone for a utc timestamp" do- Time.use_zone("UTC") do- time = Time.zone.local(2013, 6, 30, 23, 59)- expect(format_time_as_date(time, format)).to eq "01/07/2013"- end+ time = ActiveSupport::TimeZone["UTC"].local(2013, 6, 30, 23, 59)+ expect(format_time_as_date(time, format)).to eq "01/07/2013"endit "returns a date in the user timezone for a non-utc timestamp" do- Time.use_zone("Berlin") do- time = Time.zone.local(2013, 6, 30, 23, 59)- expect(format_time_as_date(time, format)).to eq "01/07/2013"- end+ time = ActiveSupport::TimeZone["Berlin"].local(2013, 6, 30, 23, 59)+ expect(format_time_as_date(time, format)).to eq "01/07/2013"endenddescribe "without user time zone" do- before { allow(User.current).to receive(:time_zone).and_return(nil) }+ let(:user_time_zone) { "" }- it "returns a date in the local system timezone for a utc timestamp" do- Time.use_zone("UTC") do- time = Time.zone.local(2013, 6, 30, 23, 59)- allow(time).to receive(:localtime).and_return(ActiveSupport::TimeZone["Athens"].local(2013, 7, 1, 1, 59))- expect(format_time_as_date(time, format)).to eq "01/07/2013"- end+ it "returns a date in the utc timezone for a utc timestamp" do+ time = ActiveSupport::TimeZone["UTC"].local(2013, 6, 30, 23, 59)+ expect(format_time_as_date(time, format)).to eq "30/06/2013"end- it "returns a date in the original timezone for a non-utc timestamp" do- Time.use_zone("Berlin") do- time = Time.zone.local(2013, 6, 30, 23, 59)- expect(format_time_as_date(time, format)).to eq "30/06/2013"- end+ it "returns a date in the utc timezone for a non-utc timestamp" do+ time = ActiveSupport::TimeZone["Berlin"].local(2013, 6, 30, 23, 59)+ expect(format_time_as_date(time, format)).to eq "30/06/2013"endendend