fix-32532.patch

Mizuki ISHIKAWA, 2019-11-29 09:07

Download (2.12 KB)

View differences:

lib/redmine/database.rb
69 69
      # Returns a SQL statement to cast a timestamp column to a date given a time zone
70 70
      # Returns nil if not implemented for the current database
71 71
      def timestamp_to_date(column, time_zone)
72
        return nil unless postgresql? || mysql?
73
        # param:time_zone or config.time_zone
74
        identifier = ActiveSupport::TimeZone.find_tzinfo((time_zone || Time.zone).name).identifier
75

  
72 76
        if postgresql?
73
          if time_zone
74
            identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier
75
            "(#{column}::timestamptz AT TIME ZONE '#{identifier}')::date"
76
          else
77
            "#{column}::date"
78
          end
79
        elsif mysql?
80
          if time_zone
81
            user_identifier = ActiveSupport::TimeZone.find_tzinfo(time_zone.name).identifier
82
            local_identifier = ActiveSupport::TimeZone.find_tzinfo(Time.zone.name).identifier
83
            "DATE(CONVERT_TZ(#{column},'#{local_identifier}', '#{user_identifier}'))"
84
          else
85
            "DATE(#{column})"
86
          end
77
          "(#{column}::timestamptz AT TIME ZONE '#{identifier}')::date"
78
        else
79
          # MySQL:
80
          # convert from local time zone to tz
81
          "DATE(CONVERT_TZ(#{column}, @@session.time_zone, '#{identifier}'))"
87 82
        end
88 83
      end
89 84

  
test/functional/issues_controller_test.rb
443 443
      }
444 444
    )
445 445
    assert_response :success
446

  
447 446
    # group_name depends on localtime
448
    group_name = format_date(Issue.second.created_on.localtime)
447
    group_name = format_date(User.current.time_to_date(Issue.second.created_on))
449 448
    assert_select 'tr.group span.name', :text => group_name do
450 449
      assert_select '+ span.count', :text => '2'
451 450
    end