Some of the feeds that I am importing have feed items dated in the future. This forces them to the top of all my search results and effectively pins them there for good. I needed a method to remove those.

Following is a patch designed to work on the Publication date field from RSS importers.

Ideally it would be extended to encompass a range of dates. Eg:
From: -1Y
To: -2W

But that isn't my current use case.

Hope someone finds it useful.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

queenvictoria’s picture

Patch attached

queenvictoria’s picture

Updated to accept specific dates. Use case: Published date is sometimes not set in RSS feeds (or set to zero which can render 1900-01-01T06:00:00Z for example). Or you might just want recent articles to come in.

So invert the filter and set the date to 1990-01-01 to filter out items prior to 1990.

The new date field in this filter will accept relative times too. So you can say
"-2 years"
or
"last Friday two years ago"
or anything else supported by strtotime http://php.net/manual/en/function.strtotime.php

Leaving the date field empty will assume `now()`. So by default (without arguments) it will filter out future items.

queenvictoria’s picture

Does anyone know--is the reason that testbot isn't looking at this because there are no tests written for it?

Als’s picture

Trying your filter, really useful considering that to skip content depending on its date is standard practice in data flows.

The filter appears in tamper, the configuration works. I can set the date, the system checks it upon save, the import results are the exact opposite if I check "invert".

However, I am not able to have the filter understand the date passed for the check. I have tried to import dates in the following formats (CSV import):
YYYY/MM/DD
YYYY-MM-DD
DD/MM/YYYY
DD-MM-YYYY

Time is never present.
The date configured in the filter falls in the middle of the imported nodes, so I should see some imported and some skipped. Instead, it is all or nothing (hence I understand that the "invert" option is working).

Thanks in advance for any help!

Als’s picture

Answering my own question: the filter understands a date in Unix format (timestamp). Would be good to write it on screen in the description.

The standard Feeds Tamper package already has a plugin to convert an English date to timestamp. So, all I need now is a sed rule to tamper the CSV so my Italian dates (oh well!) become English.

Even if I am the only one who provided feedback in 9 months, I urge the maintainer of the module to include this date filter ASAP. It is really something you would expect to be able to filter on.

Als’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
twistor’s picture

Title: Filter to prevent the import of future dated feed items » Plugin: Filter by date
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

This should really be more generic to apply.

Also, I wonder if it would be more useful to filter by number. Either greater, less than or equal to. And just convert the date to a timestamp using another plugin.

Status: Needs work » Needs review
Marelmel’s picture

Thank you for the patchs