Hi,
I generate in RoR an XML file representing Oracle database data, which is then sent to an Adobe Flex UI as an HTTP Web Service. In order to format DATES in a way that Flex understands, I add the following code to environment.rb :
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge! ( :flex => '%a %b %d %H:%M:%S %Y' )
Then, I temporarily modify the formatting of my datetime data, in this function :
def list_timespan_flexdateformat_xml old_proc = Hash::XML_FORMATTING['datetime'] Hash::XML_FORMATTING['datetime'] = Proc.new { |datetime| datetime.to_s(:flex2) }
@rv_wrk_calendar_events = RvWrkCalendarEvent.find( :all, :conditions => [ "start_date >= ? and start_date <= ?", # Une alternative, au cas où... : #:all, :conditions => [ "start_date >= to_date(?, 'YYYY-MM-DD') and start_date <= to_date(?, 'YYYY-MM-DD')",
params[:min_start_date], params[:max_start_date]]) render :xml => @rv_wrk_calendar_events.to_xml
Hash::XML_FORMATTING['datetime'] = old_proc end
This works well for all Oracle DATE fields that contain TIME information. But for some mysterious reason, it doesn't work when the DATE field doesn't contain TIME information. The only meager result is that some formats (e.g., '%Y %m %d', '%Y/%m/%d' or '%Y-%m-%d') generate this :
<start_date type="datetime">2007-08-23</start_date>
instead of the default :
<start_date type="datetime">2007-08-23T00:00:00+02:00</start_date>
I tried replacing "datetime" with "time" in the code above, to no avail...
I know I can eventually parse the date in Flex, but this problem is driving me crazy!
Chris.