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