Hi, Time.today fails on my server and works on my dev machine, both run Rails 2.3.3. What''s going on? -- Posted via http://www.ruby-forum.com/.
2009/8/28 Fernando Perez <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > Hi, > > Time.today fails on my server and works on my dev machine, both run > Rails 2.3.3. What''s going on?Are you sure you are not confusing it with Date.today? I was not aware that there is a Time.today. There is a Time.now. Colin
> Are you sure you are not confusing it with Date.today? I was not > aware that there is a Time.today. There is a Time.now. > > ColinOn my dev Machine: $ ./script/console Loading development environment (Rails 2.3.3)>> Time.now=> Fri Aug 28 22:51:16 0200 2009>> Time.today=> Fri Aug 28 00:00:00 0200 2009 I do admit there is a problem with the time returned, but still the method call worked. -- Posted via http://www.ruby-forum.com/.
On Aug 28, 4:56 pm, Fernando Perez <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > Time.today fails on my server and works on my dev machine, both run > Rails 2.3.3. What''s going on? > -- > Posted viahttp://www.ruby-forum.com/.Whats are the respective Ruby versions? Time.today exists on 1.8.7, but not 1.9.1 (or 1.8.6 to my knowledge)
> Time.today exists on 1.8.7, > but not 1.9.1 (or 1.8.6 to my knowledge)Damn that''s the answer! -- Posted via http://www.ruby-forum.com/.
You can do something like this (utilizing a Rails time method): class Time def self.today Time.now.beginning_of_day end end>> Time.today=> Mon Aug 31 00:00:00 +1200 2009 Regards Kieran On Aug 29, 8:24 pm, Fernando Perez <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Time.today exists on 1.8.7, > > but not 1.9.1 (or 1.8.6 to my knowledge) > > Damn that''s the answer! > -- > Posted viahttp://www.ruby-forum.com/.
Time has no today method, today is a Date method added by rails, as in Date.today. The method that looks like the same in time is Time.now. - Maurício Linhares http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr On Sun, Aug 30, 2009 at 4:58 PM, Kieran P<kieran776-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > You can do something like this (utilizing a Rails time method): > > class Time > def self.today > Time.now.beginning_of_day > end > end > >>> Time.today > => Mon Aug 31 00:00:00 +1200 2009 > > Regards > Kieran > > On Aug 29, 8:24 pm, Fernando Perez <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> > Time.today exists on 1.8.7, >> > but not 1.9.1 (or 1.8.6 to my knowledge) >> >> Damn that''s the answer! >> -- >> Posted viahttp://www.ruby-forum.com/. > > >
Date.today is part of Ruby standard library (not added by Rails). jeremy 2009/8/30 Maurício Linhares <linhares.mauricio-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Time has no today method, today is a Date method added by rails, as in > Date.today. > > The method that looks like the same in time is Time.now. > > - > Maurício Linhares > http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr > > > > On Sun, Aug 30, 2009 at 4:58 PM, Kieran P<kieran776-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> You can do something like this (utilizing a Rails time method): >> >> class Time >> def self.today >> Time.now.beginning_of_day >> end >> end >> >>>> Time.today >> => Mon Aug 31 00:00:00 +1200 2009 >> >> Regards >> Kieran >> >> On Aug 29, 8:24 pm, Fernando Perez <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> >> wrote: >>> > Time.today exists on 1.8.7, >>> > but not 1.9.1 (or 1.8.6 to my knowledge) >>> >>> Damn that''s the answer! >>> -- >>> Posted viahttp://www.ruby-forum.com/. >> > >> > > > >
Hi, here''s my results for the various Ruby implementations: Ruby 1.8.6:>> Time.now=> Sun Aug 30 13:49:32 -0700 2009>> Time.todayNoMethodError: undefined method `today'' for Time:Class from (irb):2>> Date.today=> Sun, 30 Aug 2009>> quitRuby 1.8.7:>> Time.now=> 2009-08-30 13:51:31 -0700>> Time.todayNoMethodError: undefined method `today'' for Time:Class from (irb):2 from /opt/local/bin/irb:12:in `<main>''>> quitRuby 1.9.1:>> Time.now=> 2009-08-30 13:54:31 -0700>> Time.todayNoMethodError: undefined method `today'' for Time:Class from (irb):2 from /opt/local/bin/irb:12:in `<main>''>> quitGood luck, -Conrad On Sun, Aug 30, 2009 at 1:43 PM, Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> > Date.today is part of Ruby standard library (not added by Rails). > > jeremy > > 2009/8/30 Maurício Linhares <linhares.mauricio-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > > > Time has no today method, today is a Date method added by rails, as in > > Date.today. > > > > The method that looks like the same in time is Time.now. > > > > - > > Maurício Linhares > > http://codeshooter.wordpress.com/ | http://twitter.com/mauriciojr > > > > > > > > On Sun, Aug 30, 2009 at 4:58 PM, Kieran P<kieran776-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >> You can do something like this (utilizing a Rails time method): > >> > >> class Time > >> def self.today > >> Time.now.beginning_of_day > >> end > >> end > >> > >>>> Time.today > >> => Mon Aug 31 00:00:00 +1200 2009 > >> > >> Regards > >> Kieran > >> > >> On Aug 29, 8:24 pm, Fernando Perez <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > >> wrote: > >>> > Time.today exists on 1.8.7, > >>> > but not 1.9.1 (or 1.8.6 to my knowledge) > >>> > >>> Damn that''s the answer! > >>> -- > >>> Posted viahttp://www.ruby-forum.com/. > >> > > >> > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Aug 30, 4:57 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, here''s my results for the various Ruby implementations: > > Ruby 1.8.6: > > >> Time.now > > => Sun Aug 30 13:49:32 -0700 2009>> Time.today > > NoMethodError: undefined method `today'' for Time:Class > from (irb):2>> Date.today > > => Sun, 30 Aug 2009 > > >> quit > > Ruby 1.8.7: > > >> Time.now > > => 2009-08-30 13:51:31 -0700>> Time.today > > NoMethodError: undefined method `today'' for Time:Class > from (irb):2 > from /opt/local/bin/irb:12:in `<main>'' > > >> quit > > Ruby 1.9.1: > > >> Time.now > > => 2009-08-30 13:54:31 -0700>> Time.today > > NoMethodError: undefined method `today'' for Time:Class > from (irb):2 > from /opt/local/bin/irb:12:in `<main>'' > > >> quit > > Good luck, > > -ConradWhat does the RUBY_VERSION say? It looks like you accidentally ran the wrong IRB when testing this out, as your Ruby "1.8.7" and 1.9.1 are both the same executable (/opt/ local/bin/irb). But Keiran''s suggestion isn''t bad, might want to work a method_defined? in with that though.
Hi, it''s actually two different machines. -Conrad On Sun, Aug 30, 2009 at 2:08 PM, pharrington <xenogenesis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Aug 30, 4:57 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Hi, here''s my results for the various Ruby implementations: > > > > Ruby 1.8.6: > > > > >> Time.now > > > > => Sun Aug 30 13:49:32 -0700 2009>> Time.today > > > > NoMethodError: undefined method `today'' for Time:Class > > from (irb):2>> Date.today > > > > => Sun, 30 Aug 2009 > > > > >> quit > > > > Ruby 1.8.7: > > > > >> Time.now > > > > => 2009-08-30 13:51:31 -0700>> Time.today > > > > NoMethodError: undefined method `today'' for Time:Class > > from (irb):2 > > from /opt/local/bin/irb:12:in `<main>'' > > > > >> quit > > > > Ruby 1.9.1: > > > > >> Time.now > > > > => 2009-08-30 13:54:31 -0700>> Time.today > > > > NoMethodError: undefined method `today'' for Time:Class > > from (irb):2 > > from /opt/local/bin/irb:12:in `<main>'' > > > > >> quit > > > > Good luck, > > > > -Conrad > > What does the RUBY_VERSION say? > > It looks like you accidentally ran the wrong IRB when testing this > out, as your Ruby "1.8.7" and 1.9.1 are both the same executable (/opt/ > local/bin/irb). > > But Keiran''s suggestion isn''t bad, might want to work a > method_defined? in with that though. > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Aug 30, 5:08 pm, pharrington <xenogene...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 30, 4:57 pm, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hi, here''s my results for the various Ruby implementations: > > > Ruby 1.8.6: > > > >> Time.now > > > => Sun Aug 30 13:49:32 -0700 2009>> Time.today > > > NoMethodError: undefined method `today'' for Time:Class > > from (irb):2>> Date.today > > > => Sun, 30 Aug 2009 > > > >> quit > > > Ruby 1.8.7: > > > >> Time.now > > > => 2009-08-30 13:51:31 -0700>> Time.today > > > NoMethodError: undefined method `today'' for Time:Class > > from (irb):2 > > from /opt/local/bin/irb:12:in `<main>'' > > > >> quit > > > Ruby 1.9.1: > > > >> Time.now > > > => 2009-08-30 13:54:31 -0700>> Time.today > > > NoMethodError: undefined method `today'' for Time:Class > > from (irb):2 > > from /opt/local/bin/irb:12:in `<main>'' > > > >> quit > > > Good luck, > > > -Conrad > > What does the RUBY_VERSION say? > > It looks like you accidentally ran the wrong IRB when testing this > out, as your Ruby "1.8.7" and 1.9.1 are both the same executable (/opt/ > local/bin/irb). > > But Keiran''s suggestion isn''t bad, might want to work a > method_defined? in with that though.And this is me speaking apparently too soon from my laptop (Kubuntu 9.03) irb(main):006:0> RUBY_VERSION => "1.8.7" irb(main):007:0> Time.today NoMethodError: undefined method `today'' for Time:Class from (irb):7 irb(main):008:0> from my desktop (also Kubuntu 9.03)>> RUBY_VERSION=> "1.8.7">> Time.today=> Sun Aug 30 00:00:00 -0400 2009>>So a gem must be adding this somewhere, I''m too lazy to look where right now though