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. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Chris> > Im not sure if this will help with the oracle case but I had to do a > similar thing. > > I ended up doing this: > > In Rails > xml.start_date(@project.start_date.to_s) > > and in flex > theNode.start_date = project.startDate.toUTCString(); > > If your dates dont have time information - can you not just go > start_date.to_time which will add 00:00:00 to your date. So, you can in your > model > > (pseudo code) > def start_date > start_date.to_time unless start_date has time component. > end > > Im not sure if this will do what you want but I hope it helps - i remember > also struggling my ass of with dates and flex and rails. > > Good luck. > Ivor > > On 8/31/07, gers32 <cbu.kitry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > 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. > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi gers32, you can take a look at strftime example: Date.now.strftime("%d/%m/%Y %H:%M:%S") Time.now.stftime("%d/%m/%Y %H:%M:%S") and if you large code base already written, then try overriding to_s method of Date/DateTime/Time(which is relevent to you) in your application.rb On Aug 31, 6:09 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Chris > > > > > Im not sure if this will help with the oracle case but I had to do a > > similar thing. > > > I ended up doing this: > > > In Rails > > xml.start_date(@project.start_date.to_s) > > > and in flex > > theNode.start_date = project.startDate.toUTCString(); > > > If your dates dont have time information - can you not just go > > start_date.to_time which will add 00:00:00 to your date. So, you can in your > > model > > > (pseudo code) > > def start_date > > start_date.to_time unless start_date has time component. > > end > > > Im not sure if this will do what you want but I hope it helps - i remember > > also struggling my ass of with dates and flex and rails. > > > Good luck. > > Ivor > > > On 8/31/07, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > 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.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, The reason I modify Hash::XML_FORMATTING[''datetime''] locally is because I might need to use another Date format in my XML somewhere else in the application. The issue, really, is that Rails somehow treats different Date fields of my Oracle database differently... On Aug 31, 3:16 pm, raghukumar <raghukumar.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi gers32, > you can take a look at strftime > example: > Date.now.strftime("%d/%m/%Y %H:%M:%S") > Time.now.stftime("%d/%m/%Y %H:%M:%S") > > and if you large code base already written, then try overriding to_s > method of Date/DateTime/Time(which is relevent to you) in your > application.rb > > On Aug 31, 6:09 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi Chris > > > > Im not sure if this will help with the oracle case but I had to do a > > > similar thing. > > > > I ended up doing this: > > > > In Rails > > > xml.start_date(@project.start_date.to_s) > > > > and in flex > > > theNode.start_date = project.startDate.toUTCString(); > > > > If your dates dont have time information - can you not just go > > > start_date.to_time which will add 00:00:00 to your date. So, you can in your > > > model > > > > (pseudo code) > > > def start_date > > > start_date.to_time unless start_date has time component. > > > end > > > > Im not sure if this will do what you want but I hope it helps - i remember > > > also struggling my ass of with dates and flex and rails. > > > > Good luck. > > > Ivor > > > > On 8/31/07, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > 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.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I quick google revieled a number of hits from various fields where the date was an issue in oracle. I found this link http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10749/ch4datetime.htm from the section on DATE datatype: <quote> A date can be specified as an ANSI date literal or as an Oracle date value. An ANSI date literal contains no time portion and must be specified in exactly the following format: DATE ''YYYY-MM-DD'' The following is an example of an ANSI date literal: DATE ''1998-12-25'' Alternatively, you can specify an Oracle date value as shown in the following example: TO_DATE(''1998-DEC-25 17:30'',''YYYY-MON-DD HH24:MI'',''NLS_DATE_LANGUAGE=AMERICAN'') </quote> Im probably way of the mark since I know nothing about oracle but that''s my 2 cents worth. Why dont you just .to_time your date before you send it over to flex? Regards Ivor On 8/31/07, gers32 <cbu.kitry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, > > The reason I modify Hash::XML_FORMATTING[''datetime''] locally is > because I might need to use another Date format in my XML somewhere > else in the application. > > The issue, really, is that Rails somehow treats different Date fields > of my Oracle database differently... > > On Aug 31, 3:16 pm, raghukumar <raghukumar.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi gers32, > > you can take a look at strftime > > example: > > Date.now.strftime("%d/%m/%Y %H:%M:%S") > > Time.now.stftime("%d/%m/%Y %H:%M:%S") > > > > and if you large code base already written, then try overriding to_s > > method of Date/DateTime/Time(which is relevent to you) in your > > application.rb > > > > On Aug 31, 6:09 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Chris > > > > > > Im not sure if this will help with the oracle case but I had to do a > > > > similar thing. > > > > > > I ended up doing this: > > > > > > In Rails > > > > xml.start_date(@project.start_date.to_s) > > > > > > and in flex > > > > theNode.start_date = project.startDate.toUTCString(); > > > > > > If your dates dont have time information - can you not just go > > > > start_date.to_time which will add 00:00:00 to your date. So, you can > in your > > > > model > > > > > > (pseudo code) > > > > def start_date > > > > start_date.to_time unless start_date has time component. > > > > end > > > > > > Im not sure if this will do what you want but I hope it helps - i > remember > > > > also struggling my ass of with dates and flex and rails. > > > > > > Good luck. > > > > Ivor > > > > > > On 8/31/07, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I quick google revieled a number of hits from various fields where the date was an issue in oracle. I found this link http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10749/ch4datetime.htm from the section on DATE datatype: <quote> A date can be specified as an ANSI date literal or as an Oracle date value. An ANSI date literal contains no time portion and must be specified in exactly the following format: DATE ''YYYY-MM-DD'' The following is an example of an ANSI date literal: DATE ''1998-12-25'' Alternatively, you can specify an Oracle date value as shown in the following example: TO_DATE(''1998-DEC-25 17:30'',''YYYY-MON-DD HH24:MI'',''NLS_DATE_LANGUAGE=AMERICAN'') </quote> Im probably way of the mark since I know nothing about oracle but that''s my 2 cents worth. Why dont you just .to_time your date before you send it over to flex? Regards Ivor On 8/31/07, gers32 <cbu.kitry-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hi, > > The reason I modify Hash::XML_FORMATTING[''datetime''] locally is > because I might need to use another Date format in my XML somewhere > else in the application. > > The issue, really, is that Rails somehow treats different Date fields > of my Oracle database differently... > > On Aug 31, 3:16 pm, raghukumar <raghukumar.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi gers32, > > you can take a look at strftime > > example: > > Date.now.strftime("%d/%m/%Y %H:%M:%S") > > Time.now.stftime("%d/%m/%Y %H:%M:%S") > > > > and if you large code base already written, then try overriding to_s > > method of Date/DateTime/Time(which is relevent to you) in your > > application.rb > > > > On Aug 31, 6:09 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Chris > > > > > > Im not sure if this will help with the oracle case but I had to do a > > > > similar thing. > > > > > > I ended up doing this: > > > > > > In Rails > > > > xml.start_date(@project.start_date.to_s) > > > > > > and in flex > > > > theNode.start_date = project.startDate.toUTCString(); > > > > > > If your dates dont have time information - can you not just go > > > > start_date.to_time which will add 00:00:00 to your date. So, you can > in your > > > > model > > > > > > (pseudo code) > > > > def start_date > > > > start_date.to_time unless start_date has time component. > > > > end > > > > > > Im not sure if this will do what you want but I hope it helps - i > remember > > > > also struggling my ass of with dates and flex and rails. > > > > > > Good luck. > > > > Ivor > > > > > > On 8/31/07, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Yes, I''ll probably have to do that. I was hoping I could keep the default Rails behavior and just be able to configure how it generates the XML, without having to override the code... Thanks, Chris. On Aug 31, 5:30 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I quick google revieled a number of hits from various fields where the date > was an issue in oracle. > > I found this link > > http://download-uk.oracle.com/docs/cd/B14117_01/server.101/b10749/ch4... > > from the section on DATE datatype: > <quote> > > A date can be specified as an ANSI date literal or as an Oracle date value. > > An ANSI date literal contains no time portion and must be specified in > exactly the following format: > > DATE ''YYYY-MM-DD'' > > The following is an example of an ANSI date literal: > > DATE ''1998-12-25'' > > Alternatively, you can specify an Oracle date value as shown in the > following example: > TO_DATE(''1998-DEC-25 17:30'',''YYYY-MON-DD > HH24:MI'',''NLS_DATE_LANGUAGE=AMERICAN'') > </quote> > > Im probably way of the mark since I know nothing about oracle but that''s my > 2 cents worth. > > Why dont you just .to_time your date before you send it over to flex? > > Regards > Ivor > > On 8/31/07, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, > > > The reason I modify Hash::XML_FORMATTING[''datetime''] locally is > > because I might need to use another Date format in my XML somewhere > > else in the application. > > > The issue, really, is that Rails somehow treats different Date fields > > of my Oracle database differently... > > > On Aug 31, 3:16 pm, raghukumar <raghukumar.r...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi gers32, > > > you can take a look at strftime > > > example: > > > Date.now.strftime("%d/%m/%Y %H:%M:%S") > > > Time.now.stftime("%d/%m/%Y %H:%M:%S") > > > > and if you large code base already written, then try overriding to_s > > > method of Date/DateTime/Time(which is relevent to you) in your > > > application.rb > > > > On Aug 31, 6:09 pm, "Ivor Paul" <ivorp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi Chris > > > > > > Im not sure if this will help with the oracle case but I had to do a > > > > > similar thing. > > > > > > I ended up doing this: > > > > > > In Rails > > > > > xml.start_date(@project.start_date.to_s) > > > > > > and in flex > > > > > theNode.start_date = project.startDate.toUTCString(); > > > > > > If your dates dont have time information - can you not just go > > > > > start_date.to_time which will add 00:00:00 to your date. So, you can > > in your > > > > > model > > > > > > (pseudo code) > > > > > def start_date > > > > > start_date.to_time unless start_date has time component. > > > > > end > > > > > > Im not sure if this will do what you want but I hope it helps - i > > remember > > > > > also struggling my ass of with dates and flex and rails. > > > > > > Good luck. > > > > > Ivor > > > > > > On 8/31/07, gers32 <cbu.ki...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > 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.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---