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.

>> 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.

Reply via email to