Forum: Ruby on Rails Using ParseDate in for loop

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jason Gilstrap (Guest)
on 2006-05-22 03:37
(Received via mailing list)
Hi,

I'm trying to use ParseDate within a for loop but I get this error:

can't dup NilClass


Any suggestions for making this work?

Thanks,
-Jason
Pete Y. (Guest)
on 2006-05-22 05:02
(Received via mailing list)
Jason,

That's not nearly enough info for anyone to help with your problem.
Parsedate, of course, works just the same whether it's in a for loop
or not. Try posting some actual code.

Cheers,

Pete Y.
http://9cays.com/
Jason Gilstrap (Guest)
on 2006-05-22 07:07
(Received via mailing list)
for res in @response
    date1 = Date.today
    date2 = ParseDate.parsedate(date_from_string)

    if  (date1 - date2 <= 365)
        count1 += 1
    end
end
Pete Y. (Guest)
on 2006-05-23 03:39
(Received via mailing list)
The thing that's likely to be causing your error is that
date_from_string is nil.

(There are also several other problems with your code, but I'll let
you cross those bridges as you come to them.)

Pete Y.
http://9cays.com/
This topic is locked and can not be replied to.