On Sat, Apr 16, 2011 at 4:37 AM, David Kahn <[email protected]>wrote:

>
>
> On Sat, Apr 16, 2011 at 1:01 AM, Bryan Crossland <[email protected]>wrote:
>
>> On Fri, Apr 15, 2011 at 1:56 PM, David Kahn 
>> <[email protected]>wrote:
>>
>>>
>>>
>>> On Fri, Apr 15, 2011 at 1:50 PM, Michael Pavling <[email protected]>wrote:
>>>
>>>> On 15 April 2011 19:41, David Kahn <[email protected]> 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
>>
>
Am still perplexed by this output (ruby 1.8.7-p330 on 64bit/Snow Leopard):

ruby-1.8.7-p330 :001 > DateTime.now
 => #<DateTime 2011-04-18T10:35:18-05:00>
ruby-1.8.7-p330 :002 > DateTime.now + 1.day
 => #<DateTime 2247-11-07T10:35:21-05:00>

I was thinking that maybe it was due to upgrading to Snow Leopard but I
reinstalled ruby and my gemset and not success, could that be a plausible
explanation and I am missing something? Anyone have any other idea? Really
bothering me that I am getting one result and others on list getting
different.



>
>> 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 [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to