Problem/Motivation

The field formatter of the date field already allows to filter multiple values by a date range, if the field cardinality allows more than one value.
However currently it seems that the format for handling those range configurations is a bit special.
The filter values are processed by date_sql_handler::arg_replace() which provides its "very own syntax" to create a date based on the ISO 8601 notation.
I actually don't know why it does this, instead using the relative date formats provided by php.
Especially since there's no db query involved in date_prepare_entity().
But this just a side-note :)
The current notation is limited related to the usage of relative dates. It supports the usage of now which is handy but there's nothing like e.g. today.
In my concrete scenario I've to show the whole day all the dates of from today midnight (00:00:00) to tomorrow midnight.
Unfortunately with the current notation I need to know how many hours/minutes/seconds are past since 00:00:00 of today.
Here it would be great to have support for php's relative date formats.

Proposed resolution

For now I've created a patch which allows you to select which notation has to be used. Even if I'm quite sure that the usage of date_sql_handler::arg_replace() could be fully replaced in this particular case.
By default the new code uses to current notation, that way it's fully backward compatible.

Remaining tasks

User interface changes

The current patch introduces new radio elements in the field output formatter in the case it has a cardinality > 1.

API changes

none

Files: 
CommentFileSizeAuthor
date-allow-relative-dates-for-output-filter.patch4.25 KBdas-peter
PASSED: [[SimpleTest]]: [MySQL] 5,238 pass(es).
[ View ]

Comments

A big +1 from me.

This worked for us! THANK YOU! What a life saver this was in certain contexts.

This also solves this issue in the queue: http://drupal.org/node/1401688

Thank you ever so much as this works beautifully. Can we please get this officially committed soon please?

Possibly I spoke too soon and or I am forgetting something. When I go into a repeating event it shows only the one date as intended however the date that it shows is for the next event not for that specific events date.

For example I have a repeating event the third Friday of each month. So my dates should be:

Friday, February 15, 2013
Friday, March 16, 2012
Friday, April 20, 2012

And so on. What I want to do is to show a event list with a view but instead of showing the next coming up event show the rrule date that is associated with that entry if that makes sense.

Is there any way to do that?

Thanks in advance

Issue summary:View changes
Status:Needs review» Needs work
Issue tags:+Needs tests

all feature requests should be covered by tests

Status:Needs work» Needs review

Iv been using this patch and we're having some wierd problems with timezone.

(line 502 date.module)

<?php
         $range
[0] = new DateObject($from, date_default_timezone());
        
$range[1] = new DateObject($to, date_default_timezone());
?>

When you create the relative notation dates they get created in local time... and this is kinda bad if your local timezone is not UTC because below in the loop where we remove the multiple values it gets compared to the default UTC database timestamps...

I tried to change to "new DateObject($from, 'UTC');" but DateObject does not even seem to work with adding a timezone?

My solution:

<?php
      $range
[0] = new DateObject($from);
     
$range[0]->setTimezone(new DateTimeZone('UTC'));
     
$range[1] = new DateObject($to);
     
$range[1]->setTimezone(new DateTimeZone('UTC'));
?>

Issue tags:+sprint