adzap/timeliness — pull request #4 by jimherz (2011-10-20 22:13:38+00:00)
Title: Fix parsing error when month is '0' or '00'

Hi,

Timeliness doesn't seem to like parsing '0' or '00' as month values. In such cases, Timeliness::Parser.parse should simply return nil because the date string is invalid. But here is what currently happens in a few cases:

```ruby
Loading development environment (Rails 3.0.7)
ree-1.8.7-2010.02 > Timeliness::Parser.parse('00/01/11')
=> Sat Jan 01 00:00:00 UTC 2011
ree-1.8.7-2010.02 > Timeliness::Parser.parse('0/01/11')
=> Sat Jan 01 00:00:00 UTC 2011
ree-1.8.7-2010.02 > Timeliness::Parser.parse('00/01/11', :date)
NoMethodError: undefined method `<' for nil:NilClass
from /.../gems/activesupport-3.0.7/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /.../gems/timeliness-0.3.4/lib/timeliness/parser.rb:142:in `fast_date_valid_with_fallback'
from /.../gems/timeliness-0.3.4/lib/timeliness/parser.rb:24:in `make_time'
from /.../gems/timeliness-0.3.4/lib/timeliness/parser.rb:17:in `parse_without_date_conversion'
ree-1.8.7-2010.02 > Timeliness::Parser.parse('00/01/11', :datetime)
NoMethodError: undefined method `<' for nil:NilClass
from /.../gems/activesupport-3.0.7/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /.../gems/timeliness-0.3.4/lib/timeliness/parser.rb:142:in `fast_date_valid_with_fallback'
from /.../gems/timeliness-0.3.4/lib/timeliness/parser.rb:24:in `make_time'
from /../gems/timeliness-0.3.4/lib/timeliness/parser.rb:17:in `parse_without_date_conversion'
```

This pull request attempts address the issue at what I think is the root cause in Timeliness::Helpers.month_index. That method does not differentiate between '0'.to_i and ''.to_i, which both return 0.

Please consider including it in your next release.

Thanks,
Jim