lib/twilio-ruby/framework/serialize.rb in twilio-ruby-5.0.0.rc23 vs lib/twilio-ruby/framework/serialize.rb in twilio-ruby-5.0.0.rc24
- old
+ new
@@ -1,20 +1,42 @@
module Twilio
- def self.serialize_iso8601(date)
+ def self.serialize_iso8601_date(date)
if date.eql?(:unset)
date
- elsif date
+ elsif date.is_a?(Date)
date.iso8601
+ elsif date.is_a?(Time)
+ date.strftime('%Y-%m-%d')
+ elsif date.is_a?(String)
+ date
end
end
+ def self.serialize_iso8601_datetime(date)
+ if date.eql?(:unset)
+ date
+ elsif date.is_a?(Date)
+ Time.new(date.year, date.month, date.day).utc.iso8601
+ elsif date.is_a?(Time)
+ date.utc.iso8601
+ elsif date.is_a?(String)
+ date
+ end
+ end
+
def self.deserialize_rfc2822(date)
unless date.nil?
Time.rfc2822(date)
end
end
- def self.deserialize_iso8601(date)
+ def self.deserialize_iso8601_date(date)
+ unless date.nil?
+ Date.parse(date)
+ end
+ end
+
+ def self.deserialize_iso8601_datetime(date)
unless date.nil?
Time.parse(date)
end
end