Class: ActiveZuora::DateTimeField

Inherits:
Field
  • Object
show all
Defined in:
lib/active_zuora/fields/date_time_field.rb

Instance Attribute Summary

Attributes inherited from Field

#default, #name, #namespace, #zuora_name

Instance Method Summary collapse

Methods inherited from Field

#clear_changed_attributes, #define_instance_methods, #initialize

Constructor Details

This class inherits a constructor from ActiveZuora::Field

Instance Method Details

#build_xml(xml, soap, value, options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/active_zuora/fields/date_time_field.rb', line 10

def build_xml(xml, soap, value, options={})
  # All dates need to be in PST time.  Since all user-set attributes
  # in Zuora are really only dates, we'll chop off the time.
  # 2012-05-22T00:00:00-08:00
  value = value ? value.strftime("%Y-%m-%dT00:00:00-08:00") : ''
  super(xml, soap, value, options)
end

#type_cast(value) ⇒ Object



4
5
6
7
8
# File 'lib/active_zuora/fields/date_time_field.rb', line 4

def type_cast(value)
  return value if value.nil? || value.is_a?(Date)
  return value.to_datetime if value.is_a?(Time)
  value.to_datetime rescue default
end