views:

39

answers:

1

Hello,

For my application I need to handle estimated dates, for example "about Jun. 1940" needs to be accepted as plus or minus 2 years around Jun 1940. Or they could type "about 1940" needs to be accepted as plus or minus 2 years around 1940. Here is the full list of possible formats.

  • 1940
  • Nov.1940
  • Nov. 1940
  • 6 Nov.1940
  • 6 Nov. 1940
  • About (date)
  • abt. (Date)
  • say (date)
  • bef. (date)
  • before (date)
  • aft. (date)
  • After (date)
  • between (date) and (date)
  • bet. (date) and (date)

I could write my own parser but the issue is it is I am not sure how to deal with the weird spans. For example if they say about 1940 I need to say from 1938-1942. Or for June 1940 I need to say June 1 1940 to June 30 1940. I want to be able to search this really well so that is why I am converting everything to date times. Are there any gems to deal with this or any ideas on the best way in the db to handle this?

I have tried Chronic but it parses incorrectly, for example if you put in "1940" it thinks that is today at 19:40.

Any ideas?

Thanks.

A: 

I am not sure if you are going to be able to get out of this without writing your own parser. I did find this, I have not used it, but it might get you started.

http://github.com/technoweenie/relative_time_helpers

Geoff Lanotte
Yeah that will help, my displaying is not the issue, does anyone have any ideas for a good database model of some sort?
Joe