On Jun 20, 2006, at 3:02 PM, <noreply / rubyforge.org>  
<noreply / rubyforge.org> wrote:

> Bugs item #4820, was opened at 2006-06-20 15:12
> You can respond by visiting:
> http://rubyforge.org/tracker/? 
> func=detail&atid=1698&aid=4820&group_id=426
>
> Category: Standard Library
> Group: None
> Status: Open
> Resolution: None
> Priority: 3
> Submitted By: Philip Hallstrom (phallstrom)
> Assigned to: Nobody (None)
> Summary: XMLRPC's conv2value does not handle DateTime at all (it  
> chops the time off)
>
> Initial Comment:
> I have been building a XML-RPC web service using Rails.  I have  
> several :datetime fields in my database.  Upon receiving the result  
> of the XML-RPC call those fields would have their time truncated to  
> 00:00:00.  Tracking the process all the way through it seems the  
> error is near line 297 of /usr/local/lib/ruby/1.8/xmlrpc/create.rb:
>
> --------------------------------------------------------------------
> when Date
>   t = param
>   @writer.tag("dateTime.iso8601",
>   format("%.4d%02d%02dT00:00:00", t.year, t.month, t.day))
> --------------------------------------------------------------------
>
> I don't know why, but "case param" when param.class == DateTime  
> would still match  the Date clause.  param.is_a?(Date) would return  
> true.

$ ruby -rdate -e 'p DateTime.ancestors'
[DateTime, Date, Comparable, Object, Kernel]

> I changed the above to look like this:
>
>
> --------------------------------------------------------------------
> when Date
>   @writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S"))
> --------------------------------------------------------------------
>
> Which seems to work well for both DateTime's and Date's.

An extra when for DateTime above Date would work too...

-- 
Eric Hodel - drbrain / segment7.net - http://blog.segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com