I am in need of a flexible PHP date parser class that can convert written English dates (both absolute and relative) to a fixed format (e.g. YYYY-MM-DD).
Importantly, the code must be CLEAN and CLEAR (with comments), in such a way that new rules/patterns can be easily added and removed, with important date manipulation functions abstracted and factored into their own methods. The class should be written as a PHP class with a public static method parse(string) and give the following results:
Relative examples (assuming server has date 2009-10-08): "a day ago" => 2009-10-07
"three days ago" => 2009-10-05
"2 wks ago" => 2009-09-24
"tomorrow" => 2009-10-09
"next monday" => 2009-10-14
"next month" => 2009-11-01
"in 2 months" => 2009-12-08
"last month" => 2009-09-01
"in three days" => 2009-10-11
Absolute examples (assuming same server date as above):
"November 1st" => 2009-11-01
"3 December" => 2009-12-03
"September 19 => 2010-09-19
"2010/09/10" => 2010-09-10
"2009/31/12" => 2009-12-31 (notice that yyyy/mm/dd is impossible!) "1992-10-22" => 1992-10-22
"August 23, 2010" => 2010-08-23
"31 October 1990" => 1990-11-31
## Deliverables
Must not rely on other packages, non-standard classes, etc. That is, it must be fully contained within itself and can only use what's available in the PHP5 library (no deprecated methods either).