Project

General

Profile

Defect #32532 » fix-32532.patch

Mizuki ISHIKAWA, 2019-11-29 09:07

View differences:

lib/redmine/database.rb
# Returns a SQL statement to cast a timestamp column to a date given a time zone
# Returns nil if not implemented for the current database
def timestamp_to_date(column, time_zone)
return nil unless postgresql? || mysql?
# param:time_zone or config.time_zone
identifier = ActiveSupport::TimeZone.find_tzinfo((time_zone || Time.zone).name).identifier
if postgresql?
if time_zone
identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier
"(#{column}::timestamptz AT TIME ZONE '#{identifier}')::date"
else
"#{column}::date"
end
elsif mysql?
if time_zone
user_identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier
local_identifier = ActiveSupport::TimeZone.find_tzinfo(Time.zone.name).identifier
"DATE(CONVERT_TZ(#{column},'#{local_identifier}', '#{user_identifier}'))"
else
"DATE(#{column})"
end
"(#{column}::timestamptz AT TIME ZONE '#{identifier}')::date"
else
# MySQL:
# convert from local time zone to tz
"DATE(CONVERT_TZ(#{column}, @@session.time_zone, '#{identifier}'))"
end
end
test/functional/issues_controller_test.rb
}
)
assert_response :success
# group_name depends on localtime
group_name = format_date(Issue.second.created_on.localtime)
group_name = format_date(User.current.time_to_date(Issue.second.created_on))
assert_select 'tr.group span.name', :text => group_name do
assert_select '+ span.count', :text => '2'
end
(2-2/2)