In the node display there are 4 Smart date formats. But none of them show the duration. It makes sense to show the duration. Also the custom formatter, does not support display of duration. Duration field is available as a field in views and there is no way to display it in the node as of now.

I also understand that the duration field in views is calculated on the fly and is not stored in database. I have seen the documentation and it says one of the main goals is to improve performance in using the date fields. This causes a minor performance lag, as all the durations has to be calculated again, every time the view is accessed. I think it is better to store the duration as field in the database, and recalculate only when the field is edited.

This has 2 advantages. It reduces the number of times duration is calculated and secondly, a duration field is available for use in nodes as well as views.

Comments

kiranpalla created an issue. See original summary.

mandclu’s picture

Actually the duration is stored, for the reasons you cited.

I'd be open to developing a way to show the duration in the node view. Would you want this in addition to the time range display, or instead of it? It seems like the simplest approach would be to allow the format to configure showing either the range or the start and duration. In the latter case the separator would be used between the start and the duration. It would also be simpler if we could always assume the start should come before the duration.

How much control would we need over the display of the duration? I could see a typical use case where you would want to collapse units to the largest applicable (e.g. 1h 30m or 7d 2h) but also some cases where you would want to force a particular unit (e.g. 90m).

mandclu’s picture

Status: Active » Needs review
StatusFileSize
new0 bytes

The attached patch adds a new "duration" formatter, with a configurable separator. Let me know if this provides the output option you need.

mandclu’s picture

StatusFileSize
new4.38 KB

Oops rolled an empty patch. Try this one instead.

mandclu’s picture

StatusFileSize
new4.18 KB

Actually forgot to do a bit of code cleanup. Hopefully this patch is final.

  • mandclu committed c585346 on 8.x-2.x
    Issue #3103587 by mandclu: Show the Duration in Node display
    
mandclu’s picture

Status: Needs review » Fixed

Since we're still in alpha (and I wanted to create a new release anyway) I decided to merge this in. Please reopen if you find additional issues.

Status: Fixed » Closed (fixed)

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