Since part of the purpose of this group is to track views development, I thought I would share my solution for creating flexible date range arguments for the Date module.
Creating arguments for date fields is hard because there are so many possible ways people might want to use them. You may need to find a full date or a part of a date or you may want to look for a date + duration or maybe specify that the duration will start on the current date or some other date, etc. etc. In creating arguments for dates I have been finding that the list of arguments in views gets longer and longer, but no matter how many you create, someone will always come back and ask for another type of argument.
Webchick at Lullabot contacted me about creating a date range argument for a client she was working with and we came up with an initial plan for an argument that uses an ISO from and to date to specify a date range. As I was working with it I began to see ways to make it even more flexible by stipulating a duration instead of a to date. Then I found out that the ISO 8601 standard also has specifications for indicating date duration and time periods (I didn't realize that before) so I used the ISO standards as specifiers. I needed a way for people to get the current date and the ISO standard doesn't have that, so I set the argument up to use the @ sign as a substitute for the current date and time.
Some examples of the kinds of arguments you can use and the results you will get:.
* --------- ARGUMENT -------- >> -------- RESULTING QUERY RANGE -------- * 2006-W24 >> 24th ISO week in 2006 * 2006 >> the whole year of 2006 * 2006-03 >> the whole month of Mar 2006 * 2006-02--2006-03-15 >> Feb 1 2006 to Mar 15 2006 * 2006-08-31T14:00:00--P2H >> the 14th to 16th hours of Aug 8 2006 * @--2006-12-31 >> NOW to 2006-12-31T23:59:59 * @P3H >> NOW to three hours from now * @P1Y90D >> NOW to one year and 90 days from now * 2006-03-05--P1W >> the week starting Mar 5 2006 * 2006-01--P3M >> 3 months starting Jan 2006
The url is much longer this way, of course. But it's at least semi-intuitive (someone could figure out how to change a view to display different results). And you can use it programatically to create links to views using nearly any date criteria.
Anyway, my plan is to add something similar to the Event Views module.