Class: RailsAdmin::Config::Fields::Types::Datetime

Inherits:
Base
  • Object
show all
Defined in:
lib/rails_admin/config/fields/types/datetime.rb

Direct Known Subclasses

Date, Time, Timestamp

Constant Summary

Constants inherited from Base

Base::NAMED_INSTANCE_VARIABLES

Instance Attribute Summary

Attributes inherited from Base

#abstract_model, #defined, #name, #order, #parent, #properties, #root, #section

Instance Method Summary collapse

Methods inherited from Base

#association?, #editable?, #errors, #form_default_value, #form_value, #generic_field_help, #generic_help, #initialize, #inverse_of, #method_name, #optional, #optional=, #optional?, #type, #type_css_class, #virtual?

Methods included from Inspectable

#inspect

Methods included from Groupable

#group

Methods included from Hideable

#hidden?, #hide, included, #show

Methods included from Configurable

#has_option?, included, #register_deprecated_instance_option, #register_instance_option

Methods included from Proxyable

#bindings, #bindings=, #with

Constructor Details

This class inherits a constructor from RailsAdmin::Config::Fields::Base

Instance Method Details

#parse_input(params) ⇒ Object



19
20
21
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 19

def parse_input(params)
  params[name] = parse_value(params[name]) if params[name]
end

#parse_value(value) ⇒ Object



15
16
17
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 15

def parse_value(value)
  parser.parse_string(value)
end

#parserObject



11
12
13
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 11

def parser
  RailsAdmin::Support::Datetime.new(strftime_format)
end

#valueObject



23
24
25
26
27
28
29
30
# File 'lib/rails_admin/config/fields/types/datetime.rb', line 23

def value
  parent_value = super
  if %w(DateTime Date Time).include?(parent_value.class.name)
    parent_value.in_time_zone
  else
    parent_value
  end
end