Sha256: e894e1b870e7d903b5cdd9c38290c22af22ceb164c78e2b7e9f7fbb8cf5e151d

Contents?: true

Size: 1004 Bytes

Versions: 106

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

106 entries across 106 versions & 1 rubygems

Version Path
bullet_train-fields-1.4.1 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.4.0 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.25 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.24 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.23 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.22 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.21 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.20 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.19 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.18 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.17 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.16 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.15 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.14 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.13 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.12 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.11 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.10 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.9 app/controllers/concerns/fields/date_and_time_support.rb
bullet_train-fields-1.3.8 app/controllers/concerns/fields/date_and_time_support.rb