This is strange what happened here. Chronic parse was not able to
parse a string when it contained a range like this:

"1/1/2011 - 1/1/2012"

So in order to address this, i had to check for the "-" in the string:

if history_date.include? "-"
              date_range              =
Chronic.parse(Date.parse(history_date), :guess => false)

            else
              date_range              =
Chronic.parse(history_date, :guess => false)

            end


Im open to better solutions.

thanks for response

On Jan 1, 12:54 pm, John Merlino <[email protected]> wrote:
> Hey all,
>
> Chronic will parse a date range in console:
>
> Chronic.parse(1/1/2011 - 1/1/2012, :guess => false)
>  => 2012-01-01 12:00:00 -0500..2012-01-01 12:00:01 -0500
>
> However, when I use logger to check if it's parsing in application, it
> is not:
>
>          logger.info "The value of history date is #{history_date}" =>
> The value of history date is 1/1/2011 - 1/1/2012
>           logger.info "The value of date range is
> #{ Chronic.parse(history_date, :guess => false)}" => The value of date
> range is
>
> See how it returns nil for second logger. I have no clue why it works
> fine in console but not in application.
>
> thanks for response

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