I had a problem that the argument @--P1Y would show me all items with the date being 1/1/2008 and 1/1/2009, instead of showing events between NOW and NOW+1Y.

After a brief search it turns out that if we are in single digit months or days (which is usually the case), then '@' is expanding to 2008-9-17 for example. This is great, however it is then not matched by the REGEX in date_api, which then automatically makes a 2008-01-01 out of it. One could either change the regex (which might affect other things, I am not sure) or change what '@' expands to.

As a short solution I have patched the REGEX to accept 1-digit months and days like this:

--- date_api.module	(revision 314)
+++ date_api.module	(working copy)
@@ -33,7 +33,7 @@
 
 define('DATE_REGEX_ISO', '/(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):?(\d{2})?/');
 define('DATE_REGEX_DATETIME', '/(\d{4})-(\d{2})-(\d{2})\s(\d{2}):(\d{2}):?(\d{2})?/');
-define('DATE_REGEX_LOOSE', '/(\d{4})-?(\d{2})-?(\d{2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})?(\.\d+)?(Z|[\+\-]\d{2}:?\d{2})?)?/');
+define('DATE_REGEX_LOOSE', '/(\d{4})-?(\d{1,2})-?(\d{1,2})([T\s]?(\d{2}):?(\d{2}):?(\d{2})?(\.\d+)?(Z|[\+\-]\d{2}:?\d{2})?)?/');
 define('DATE_REGEX_ICAL_DATE', '/(\d{4})(\d{2})(\d{2})/');
 define('DATE_REGEX_ICAL_DATETIME', '/(\d{4})(\d{2})(\d{2})T(\d{2})(\d{2})(\d{2})(Z)?/');

Waldemar

Comments

karens’s picture

Status: Active » Fixed

Good detective work! This looks like a good fix anyway, since this is supposed to be a 'loose' match. Thanks! Committed to both D5 and D6 -dev versions.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.