relative date parsing
How had can that be … hard I’ve outlined in earlier journal entries some of my thoughts and stuff but I think I have a 0.1 version ready. While it still has some bumpy spots, like using a constant 30 for month offsets, it does manage to parse some pretty interesting text. This is a small set of tests I’ve been using to code against: 5 minutes from now 5 min from now 5m from now in 5 minutes 5 min 5 min before now 5 min before next week 5 hours from noon 5 hours before noon in 2 weeks 7 days before now next day next week last week next tuesday next thursday Pretty neat if I do say so myself :) Now to remove some of the hard-coded constants like 30 for months and some of the hard-coded text so that it can be data-driven to allow for internationalization. Another thing I want to do is make it allow for text like “5 days from 11/12/2004”. This seems doable but I need to use some code I have found in my travels to try and predict if a given string has a parsable date. Nothing fancy mind you, there will be plenty of exceptions and well-it- doesn’t-quite-handle-this items in the README :) “parsetime.py":http://code- bear.com:4200/svn/codebear/timeparse/branches/parsetime.py