Class: DeadSimpleCMS::Attribute::Type::Datetime
- Defined in:
- lib/dead_simple_cms/attribute/type/all.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#group_hierarchy, #input_type, #required, #section
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
#default, #hint, #initialize, #inspect, #length, #root_group?, #section_identifier, #value=
Methods included from Util::Identifier
Constructor Details
This class inherits a constructor from DeadSimpleCMS::Attribute::Type::Base
Class Method Details
.convert_attributes(attributes) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/dead_simple_cms/attribute/type/all.rb', line 51 def self.convert_attributes(attributes) date_attrs = attributes.keys.inject({}) do |new_hash, key| if key =~ /\(\d+i\)$/ attr_name = key.match(/^(.*)\(\d+i\)$/)[1] new_hash[attr_name] ||= {} new_hash[attr_name][key] = attributes.delete(key) end new_hash end if date_attrs.present? date_attrs.each do |attr_name, values| datetime = ::Time.zone.local(*values.sort.map { |v| v.second.to_i }).to_datetime attributes[attr_name] = datetime end end attributes end |
Instance Method Details
#value ⇒ Object
69 70 71 72 73 |
# File 'lib/dead_simple_cms/attribute/type/all.rb', line 69 def value if datetime_value = super datetime_value.in_time_zone.to_datetime end end |