Class: Terrazzo::Field::DateTime
- Defined in:
- lib/terrazzo/field/date_time.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
#attribute, #data, #options, #page, #resource
Instance Method Summary collapse
Methods inherited from Base
associative?, default_options, eager_load?, #field_type, field_type, #form_input_attributes, #initialize, permitted_attribute, #required?, searchable?, #serializable_options, sortable?, transform_param, with_options
Constructor Details
This class inherits a constructor from Terrazzo::Field::Base
Instance Method Details
#serialize_value(_mode) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/terrazzo/field/date_time.rb', line 4 def serialize_value(_mode) return nil if data.nil? value = if [:timezone] data.in_time_zone([:timezone]) elsif data.respond_to?(:in_time_zone) data.in_time_zone else data end format = [:format] format ? value.strftime(format) : value.iso8601 end |