0

I have an XMLRPC datetime returned from a remote API, and I want to perform normal comparison operations to a standard Ruby datetime object, such as >, <, >=, etc. I've read that XMLRPC has some strange datetime restrictions (such as it doesn't support values before or after a certain date) and using DateTime.parse() for the returned object doesn't work, with or without string interpolation.

How do you accurately convert an XMLRPC::DateTime object to a standard Ruby 2.2.2 DateTime object so I can execute comparisons, regardless of the date returned?

JimboTwice
  • 117
  • 6

1 Answers1

1

Please convert everything into epoch_in_seconds

(XMLRPC::DateTime instance).to_time.to_i

(DateTime instance).to_i

You can also convert everything in UTC to make sure you're working with the same timezone

Jean Meyer
  • 409
  • 1
  • 3
  • 12