Class: FreshBooks::XmlSerializer::DateTimeSerializer

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

Overview

FreshBooks datetimes are specified in gmt-4. This library assumes utc and will convert to the appropriate timezone.

Class Method Summary collapse

Class Method Details

.to_node(member_name, value) ⇒ Object



98
99
100
101
102
# File 'lib/freshbooks/xml_serializer/serializers.rb', line 98

def self.to_node(member_name, value)
  element = REXML::Element.new(member_name)
  element.text = (value.utc - 4.hours).to_s(:db) # hack to convert to gmt-4, any better way?
  element
end

.to_value(xml_val) ⇒ Object



104
105
106
# File 'lib/freshbooks/xml_serializer/serializers.rb', line 104

def self.to_value(xml_val)
  DateTime.parse(xml_val.text.to_s + " -04:00").utc # hack to convert from gmt-4 to utc
end