[patch] add fuzzy parsing for underspecified dates

Bug #790816 reported by Joe Blaylock
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dateutil
New
Undecided
Unassigned

Bug Description

Hi Gustavo,

I am writing to offer a patch for python-dateutil, which should apply
cleanly to the 1.x and the 2.x trees. I'm most concerned with updating
the 1.x tree. I hope Unix patch files are OK; if not please let me know
what you'd prefer. I'm also writing to get a feel for how quickly this
patch is likely to be applied. :)

I work on INSPIRE ( http://inspirebeta.net ), a repository of literature
for the high-energy physics community. INSPIRE is a new, in-development
replacement for the 40-year-old SPIRES system (
http://www.slac.stanford.edu/spires/hep/ ). Since we're replacing
SPIRES, we have to try to be at least as smart as it in at least those
areas our user community actually uses. SPIRES, having 40 years of
continuous refinement, is pretty darn smart. In particular you can do
reasonably fancy things like

find date last month

or

find date march

and it will do what you expect pretty much every time.

Currently, to support parsing of dates in weird formats, we're using
python-dateutil, and we're very happy with it, but for one thing: the
parser only gives you back datetime objects, and datetime objects can't
be used to represent indefinite periods. One of my colleagues has
written a patch to give the parser a fuzzy flag which, if true, will
cause the parser to skip its default date substitutions, and instead
return a relativedelta object when dates are underspecified.

Of course, there are unit tests too.

This behavior is enormously helpful to us in for own parser, so we're
hoping you'll accept the patch.

Thanks,
Joe

Tags: parsing
Revision history for this message
Joe Blaylock (jrbl) wrote :
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.