<commit_before>module AjaxDatatablesRails
  module Datatable
    module ColumnDateFilter

      def empty_range_search?
        (formated_value == delimiter) || (range_start.blank? && range_end.blank?)
      end

      # A range value is in form '<range_start><delimiter><range_end>'
      # This returns <range_start>
      def range_start
        @range_start ||= formated_value.split(delimiter)[0]
      end

      # A range value is in form '<range_start><delimiter><range_end>'
      # This returns <range_end>
      def range_end
        @range_end ||= formated_value.split(delimiter)[1]
      end

      # Do a range search
      def date_range_search
        return nil if empty_range_search?
        new_start = range_start.blank? ? Time.zone.parse('01/01/1970') : Time.zone.parse(range_start)
        new_end = range_end.blank? ? Time.current : Time.zone.parse("#{range_end} 23:59:59")
        table[field].between(OpenStruct.new(begin: new_start, end: new_end))
      end

      private

        def non_regex_search
          if cond == :date_range
            date_range_search
          else
            super
          end
        end

    end
  end
end<commit_msg>Added timezone support for daterange<commit_after>module AjaxDatatablesRails
  module Datatable
    module ColumnDateFilter

      def empty_range_search?
        (formated_value == delimiter) || (range_start.blank? && range_end.blank?)
      end

      # A range value is in form '<range_start><delimiter><range_end>'
      # This returns <range_start>
      def range_start
        @range_start ||= formated_value.split(delimiter)[0]
      end

      # A range value is in form '<range_start><delimiter><range_end>'
      # This returns <range_end>
      def range_end
        @range_end ||= formated_value.split(delimiter)[1]
      end

      # Do a range search
      def date_range_search
        return nil if empty_range_search?

        if Time.zone
          new_start = range_start.blank? ? Time.zone.parse('01/01/1970') : Time.zone.parse(range_start)
          new_end = range_end.blank? ? Time.current : Time.zone.parse("#{range_end} 23:59:59")
        else
          new_start = range_start.blank? ? DateTime.parse('01/01/1970') : DateTime.parse(range_start)
          new_end = range_end.blank? ? DateTime.current : DateTime.parse("#{range_end} 23:59:59")
        end
        table[field].between(OpenStruct.new(begin: new_start, end: new_end))
      end

      private

        def non_regex_search
          if cond == :date_range
            date_range_search
          else
            super
          end
        end

    end
  end
end
{'fraction_non_alphanumeric': 0.09567198177676538, 'fraction_numerical': 0.017463933181473046, 'mean_word_length': 2.4309895833333335, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3224358', 'n_tokens_mistral': 838, 'n_tokens_neox': 793, 'n_words': 178}