I use Date field with "Date and time" formatter.
For this formatter I can set "starting from" option to now ('now'), relative feature ('+1 day') or any date in format YYYY-MM-DDTHH:MM:SS.

That will be useful to set '-1 day', but as I can see, arg_parts()/arg_range() don't support relative dates with '-' (like my 'P-1D').
If I set '-1 day' it is recognized as 'now'. Is it required restriction?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

KarenS’s picture

I'm having trouble understanding, sorry. Can you try to clarify?

kalabro’s picture

FileSize
35.63 KB

I'm so sorry. One more try:

  • I have Date field with Unlimited count of values.
  • I use formatter "Date and time" for displaying my field values.
  • I want to display only values later than yesterday.
  • I'm trying to use setting "starting from" but it doesn't allow relative dates in the past.
    Screenshot of formatter settings

I looked through the code and understood that for now it can't be done, so I created feature request.

Is that will be difficult to allow any strtotime() string for flexibility and then convert it to ISO format?

kalabro’s picture

Issue summary: View changes

typo

chaps2’s picture

Issue is still present in 7.x-2.x. Patch attached which allows negative relative dates - e.g. "now -2 days".

DamienMcKenna’s picture

Status: Active » Needs review

Thanks for the patch, we'll try to review it soon.

BTW when you upload a patch it helps to set the status to "needs review", that triggers the testbots and lets others know that there's something review.

DamienMcKenna’s picture

Status: Needs review » Needs work
Issue tags: +Needs tests

I think we should add test coverage for this.