From: Sam Roberts Date: 2007-02-17T12:32:13+09:00 Subject: Re: Trouble with xmlrpc Quoting james@grayproductions.net, on Sat, Feb 17, 2007 at 07:45:44AM +0900: > On Feb 16, 2007, at 4:17 PM, Sam Roberts wrote: > >>Currently we send the time without any time-zone information. It's > >>hard to see this as useful in anyway. There is no way to add a time- > >>zone to the iso 8601 field the spec calls for either. > > > >Why do you say that? Isn't the format of the dateTime.iso8601 field > >that defined by ISO 8601? > > I'm sorry. I wasn't very clear on that point. The XML-RPC spec > calls for a particular format of an ISO 8601 date: > 19980717T14:08:55. The entirety of the specs description of dateTime.iso8601 is this: Tag Type Example [... other data types...] date/time 19980717T14:08:55 and I don't see why any sensible person would read that example, and think that a single example somehow suffices to indicate that the date format is called ISO 8601, but isn't ISO 8601. Still, its a horridly vague excuse for a "specification", the important thing is probably, what do implementations actually do? As one example, ruby's xml-rpc, code you quoted in a seperate message, does this: when /^(-?\d\d\d\d)-?(\d\d)-?(\d\d)T(\d\d):(\d\d):(\d\d)(?:Z|([+-])(\d\d):?(\d\d))?$/ a = [$1, $2, $3, $4, $5, $6].collect{|i| i.to_i} if $7 ofs = $8.to_i*3600 + $9.to_i*60 ofs = -ofs if $7=='+' utc = Time.utc(a.reverse) + ofs a = [ utc.year, utc.month, utc.day, utc.hour, utc.min, utc.sec ] That code clearly (and correctly) handles ISO 8601 date times, including variants with timezones! Unfortunately, the code in create.rb doesn't similarly handle timezones, for some reason, perhaps it should? Sam Index: lib/xmlrpc/create.rb =================================================================== --- lib/xmlrpc/create.rb (revision 11477) +++ lib/xmlrpc/create.rb (working copy) @@ -7,6 +7,7 @@ # require "date" +require "time" require "xmlrpc/base64" module XMLRPC @@ -241,9 +242,12 @@ @writer.ele("data", *a) ) - when Time, Date - @writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S")) + when Date + @writer.tag("dateTime.iso8601", param.strftime("%Y%m%dT%H:%M:%S")) + when Time + @writer.tag("dateTime.iso8601", param.iso8601) + when XMLRPC::DateTime @writer.tag("dateTime.iso8601", format("%.4d%02d%02dT%02d:%02d:%02d", *param.to_a))