From 31cd45d0a49e89162087e804492eca964908a565 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 9 Aug 2019 13:16:44 +0200 Subject: [PATCH] Fixed issue #2697 - Time zone incorrectly calculated in ticket list. --- app/controllers/reports_controller.rb | 5 +++-- spec/requests/report_spec.rb | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index be4af94ad..3fb71d9ef 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -315,8 +315,9 @@ class ReportsController < ApplicationController if timezone.present? offset = time.in_time_zone(timezone).utc_offset - time -= offset + time += offset end - time.utc.iso8601.to_s.sub(/Z$/, '') + local_time = time.utc.iso8601.to_s.sub(/Z$/, '') + local_time.sub(/T/, ' ') end end diff --git a/spec/requests/report_spec.rb b/spec/requests/report_spec.rb index ae3532e7a..9f893812a 100644 --- a/spec/requests/report_spec.rb +++ b/spec/requests/report_spec.rb @@ -81,6 +81,10 @@ RSpec.describe 'Report', type: :request, searchindex: true do expect(@response['Content-Type']).to eq('application/vnd.ms-excel') end + it 'does convert UTC timestamp to local system based timestamp' do + expect(ReportsController.new.time_in_localtime_for_excel(Time.parse('2019-08-08T01:00:05Z').in_time_zone, 'Europe/Berlin')).to eq('2019-08-08 03:00:05') + end + it 'does report example - deliver result' do skip('No ES configured') if !SearchIndexBackend.enabled?