It would be useful to have a field formatter that returns the interval in a format that can be used in php date functions.
Like what the interval_apply_interval() function does but without the $date->modify() part.

CommentFileSizeAuthor
#5 interval-php_formatter-1921184-5.patch2.09 KBrooby

Comments

rooby’s picture

Related to this and also maybe easiest to do it at once is to split the interval_apply_interval() function so that there is a function that generates an interval string (used for the php formatter) and a function that applies applies an interval string to a date.

That way the interval_apply_interval() could be used with other fields that contain a php date nterval string.

For example, #1921038-2: Recurring interval checkout pane could provide a recurring payment action that takes an interval string and uses interval_apply_interval() (as it currently does).
This would allow the recurring payment interval to be taken from an interval field (or other field containing an interval string) via a token.

Or interval_apply_interval() could remain as is and have a new function for applying an interval string (or just use DateTime::modify directly).

It's late so I could just be dreaming out loud but I will review this again tomorrow.

larowlan’s picture

Status: Active » Postponed

It uses the field api, so you can implement hook_field_formatter_info() or use Custom formatters.
Happy to accept patches but none that allow php entry by admins

rooby’s picture

Status: Postponed » Active

Yep, that's what I was planning to do.

There will be no entering php by anyone.

Patch will come tonight.

rooby’s picture

Assigned: Unassigned » rooby
rooby’s picture

Status: Active » Needs review
StatusFileSize
new2.09 KB

Patch ahoy.

larowlan’s picture

Assigned: rooby » Unassigned
Status: Needs review » Fixed

Thanks rooby
Committed as c36264e

Status: Fixed » Closed (fixed)

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

  • Commit c36264e on 7.x-1.x, 8.x-1.x authored by rooby, committed by larowlan:
    Issue #1921184 by rooby: Added php field formatter.