DateTimes get converted to Dates in XML-RPC?

Hi all -

I have written an XML-RPC app using action-web-service. Mostly works
well. Except I just noticed that my :datetime types are coming back as
:date types.

That is, when in the console I query the record via Foo.find_by_id(123)
I
get back actual datetimes. If I then do it via XML-RPC, fetching that
same record I get back dates (ie. hour/minute/second are set to
00:00:00)

Any ideas? Tried google, and ruby-forum is down and am up against a
deadline…

My api/model method looks like this:

     def find_by_id(id)
             Foo.find(id)
     end

thanks!

-philip

deadline…

My api/model method looks like this:

   def find_by_id(id)
           Foo.find(id)
   end

thanks!

To followup, Foo.find_by_id(123).to_xml spits back valid :datetimes…
so
it doesn’t appear to be some underlying xml thing. Seems it’s in
AWS…

???

-philip

Hi Philip,

Philip H. wrote:

I have written an XML-RPC app using action-web-service. Mostly works
well. Except I just noticed that my :datetime types are coming back as
:date types.

That is, when in the console I query the record via Foo.find_by_id(123) I
get back actual datetimes. If I then do it via XML-RPC, fetching that
same record I get back dates (ie. hour/minute/second are set to 00:00:00)

Any ideas? Tried google, and ruby-forum is down and am up against a
deadline…

I’m not sure I understand your question completely, but I’ll offer a
couple
of tidbits just in case one might help…

  1. Time is more “reliable” than Date

  2. You might take a look at Time.now.xmlschema

hth,
Bill

I’m not sure I understand your question completely, but I’ll offer a couple
of tidbits just in case one might help…

  1. Time is more “reliable” than Date

  2. You might take a look at Time.now.xmlschema

That’s the thing… I’m not doing really utilizing any of those. The
table has a :datetime field (created_at/updated_at). With AWS you set
up
your service, then simply make the calls to the model to fetch what you
want and return it “as is”. AWS then converts that into xml-rpc or
soap.

So, I’m “done” after doing Foo.find_by_id(123) and returning that.
Meaning I’d never have a chance to manipulate the data itself. Putting
in
a breakpoint right there shows the data is right. Somewhere in AWS it
is
truncating it…

return it “as is”. AWS then converts that into xml-rpc or soap.

So, I’m “done” after doing Foo.find_by_id(123) and returning that. Meaning
I’d never have a chance to manipulate the data itself. Putting in a
breakpoint right there shows the data is right. Somewhere in AWS it is
truncating it…

I spent all morning following the code and arrived at XMLRPC’s create.rb
conv2value method.

It’s converting paramaters into strings, and even though my param is a
DateTime it matches Date which then did this:

when Date
t = param
@writer.tag(“dateTime.iso8601”,
format("%.4d%02d%02dT00:00:00", t.year, t.month, t.day))

I changed that to this:

when Date
@writer.tag(“dateTime.iso8601”, param.strftime("%Y%m%dT%H:%M:%S"))

and it seems to work just as well…

Any gotchas I’m missing?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs