On Sat, Apr 16, 2011 at 1:01 AM, Bryan Crossland <bacrossl...@gmail.com>wrote:
> On Fri, Apr 15, 2011 at 1:56 PM, David Kahn > <d...@structuralartistry.com>wrote: > >> >> >> On Fri, Apr 15, 2011 at 1:50 PM, Michael Pavling <pavl...@gmail.com>wrote: >> >>> On 15 April 2011 19:41, David Kahn <d...@structuralartistry.com> wrote: >>> > This cant be so hard but feeling rather annoyed with myself for >>> thinking I >>> > can do the following: >>> > >>> > DateTime.now + 1.day >>> > >>> > Is there any easy way to do this? >>> >>> I prefer to use .since and .ago: >>> >>> DateTime.now.since(1.day) >>> >> >> Hmmm, I like the idea but getting an error - I am in rails console (Ruby >> 1.8.7)... but in Ruby 1.9.2 the method is present. Any idea how to aproach >> this problem in 1.8.7? >> >> ruby-1.8.7-p330 :020 > DateTime.now.since(1.day) >> NoMethodError: undefined method `since' for #<DateTime >> 2011-04-15T13:52:34-05:00> >> >> ruby-1.9.2-p136 :001 > DateTime.now.since(1.day) >> => Sat, 16 Apr 2011 13:55:22 -0500 >> >> > Which version of ActiveSupport are you running? I have ruby 1.8.7 installed > and ActiveSupport 2.3.11. I was able to run your first examples and get the > correct output as well as run Micheal's examples and get the correct > output. > Hey Brian, thanks.... so I am on activesupport (= 3.0.6) (from my gemfile lock, which I assume is reliable)... on one side I am glad that perhaps something is wrong with my environment because I have resorted to doing things like: Time.now + 1.day.seconds to get certain outcomes (gave up on datetime). So you are on Rails 2, right? I wonder if either is a difference bet R2 and R3 but I think Michael was using Ruby 1.9.2 and I assumed Rails 3. I guess I should probably drop my gemset and reinstall and see what happens.... ruby-1.8.7-p330 :001 > DateTime.now => #<DateTime 2011-04-16T04:32:20-05:00> ruby-1.8.7-p330 :002 > DateTime.now + 1.day => #<DateTime 2247-11-05T04:32:27-05:00> > > >> DateTime.now > => Sat, 16 Apr 2011 01:00:29 -0500 > >> DateTime.now + 1.day > => Sun, 17 Apr 2011 01:00:32 -0500 > > >> DateTime.now.since(1.day) > => Sun, 17 Apr 2011 01:00:34 -0500 > > B. > > -- > 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.