Class: FreshBooks::XmlSerializer::DateSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/freshbooks/xml_serializer/serializers.rb

Class Method Summary collapse

Class Method Details

.to_node(member_name, value) ⇒ Object



28
29
30
31
32
# File 'lib/freshbooks/xml_serializer/serializers.rb', line 28

def self.to_node(member_name, value)
  element = REXML::Element.new(member_name)
  element.text = value.to_s
  element
end

.to_value(xml_val) ⇒ Object



34
35
36
37
38
39
40
41
42
# File 'lib/freshbooks/xml_serializer/serializers.rb', line 34

def self.to_value(xml_val)
  begin
    Date.parse(xml_val.text.to_s) 
  rescue ArgumentError => e
    # Sometimes freshbooks gives dates that look like this 0000-00-00 00:00:00
    # just default to todays date, you have any other suggestions?
    Date.new
  end
end