Sha256: e894e1b870e7d903b5cdd9c38290c22af22ceb164c78e2b7e9f7fbb8cf5e151d

Contents?: true

Size: 1004 Bytes

Versions: 105

Compression:

Stored size: 1004 Bytes

Contents

module Fields::DateAndTimeSupport
  extend ActiveSupport::Concern

  def assign_date_and_time(strong_params, attribute)
    deprecator = ActiveSupport::Deprecation.new("2.0", "BulletTrain::Fields")
    deprecator.deprecation_warning(
      "assign_date_and_time",
      "Please assign an ISO8601 datetime string as form field value instead and remove all assign_date_and_time assignments,
      see https://ruby-doc.org/3.2.2/exts/date/DateTime.html"
    )
    attribute = attribute.to_s
    time_zone_attribute = "#{attribute}_time_zone"
    if strong_params.dig(attribute).present?
      begin
        strong_params[attribute] = DateTime.iso8601(strong_params[attribute])
      rescue ArgumentError
        time_zone = ActiveSupport::TimeZone.new(strong_params[time_zone_attribute] || current_team.time_zone)
        strong_params.delete(time_zone_attribute)
        strong_params[attribute] = time_zone.strptime(strong_params[attribute], t("global.formats.date_and_time"))
      end
    end
  end
end

Version data entries

105 entries across 105 versions & 1 rubygems

Version Path
bullet_train-fields-1.10.0 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.9.0 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.8.5 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.8.4 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.8.3 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.8.2 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.8.1 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.8.0 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.23 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.22 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.21 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.20 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.19 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.18 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.17 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.16 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.15 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.14 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.13 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.7.12 app/controllers/concerns/fields/date_and_time_support.rb