Sha256: 605ae1eb53f39bd445f0f468d561b8669b162c5bfd5cf0d1a06c9fe0da98a8aa
Contents?: true
Size: 946 Bytes
Versions: 1
Compression:
Stored size: 946 Bytes
Contents
module Avo module Fields class DateTimeField < DateField attr_reader :format attr_reader :picker_format attr_reader :time_24hr attr_reader :timezone def initialize(id, **args, &block) super(id, **args, &block) add_boolean_prop args, :time_24hr add_string_prop args, :picker_format, "Y-m-d H:i:S" add_string_prop args, :format, "yyyy-LL-dd TT" add_string_prop args, :timezone end def formatted_value return nil if value.nil? value.utc.to_time.iso8601 end def edit_formatted_value return nil if value.nil? value.utc.to_formatted_s(:db) end def fill_field(model, key, value, params) if value.nil? model[id] = nil return model end return model if value.blank? model[id] = value.in_time_zone(timezone) model end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
avo-2.9.1.pre3 | lib/avo/fields/date_time_field.rb |