app/controllers/oaisys/pmh_controller.rb
# Returning nil gives a bad argument error.
Returning nil gives a bad argument error.
Returning nil gives a bad argument error .
def handle_from_and_until_dates(model, from_date, until_date)
    if from_date.present?
      from_date_format = get_date_format(from_date)
      case from_date_format
      when :full_date_with_time
        model = model.updated_on_or_after(from_date)
      when :full_date
        model = model.updated_on_or_after(DateTime.strptime(from_date, '%Y-%m-%d'))
      else
        return nil
      end
    end
    if until_date.present?
      until_date_format = get_date_format(until_date)
      case until_date_format
      when :full_date_with_time
        just_after_until_date = (until_date.to_time + 1.second).utc.xmlschema
        model = model.updated_before(just_after_until_date)
        return nil if from_date.present? && from_date_format != :full_date_with_time
      when :full_date
        model = model.updated_before(DateTime.strptime(until_date, '%Y-%m-%d') + 1.day)
        return nil if from_date.present? && from_date_format != :full_date
      else
        return nil
      end
    end
    model
  end
def handle_from_and_until_dates ( model , from_date , until_date ) if from_date . present? from_date_format = get_date_format ( from_date ) case from_date_format when :full_date_with_time model = model . updated_on_or_after ( from_date ) when :full_date model = model . updated_on_or_after ( DateTime . strptime ( from_date , '%Y-%m-%d' ) ) else return nil end end if until_date . present? until_date_format = get_date_format ( until_date ) case until_date_format when :full_date_with_time just_after_until_date = ( until_date . to_time + 1 . second ) . utc . xmlschema model = model . updated_before ( just_after_until_date ) return nil if from_date . present? && from_date_format != :full_date_with_time when :full_date model = model . updated_before ( DateTime . strptime ( until_date , '%Y-%m-%d' ) + 1 . day ) return nil if from_date . present? && from_date_format != :full_date else return nil end end model end
Returning nil gives a bad argument error.
Returning nil gives a bad argument error .
model
<not_specific>
from_date
<not_specific>
until_date
<not_specific>