Package

ViewHelpers

ViewHelper Documentation

v:format.dateRange

Date range calculation/formatting ViewHelper

Uses DateTime and DateInterval operations to calculate a range between two DateTimes.

Usages

Note about LLL support and array consumers

When used with the "return" attribute and when this attribute is an array, the output becomes suitable for consumption by f:translate, v:l or f:format.sprintf for example - as the "arguments" attribute:

<f:translate key="myDateDisplay"
    arguments="{v:format.dateRange(intervalFormat: 'P3W', return: {0: 'w', 1: 'd'})}"
/>

Which if "myDateDisplay" is a string such as "Deadline: %d week(s) and %d day(s)" would output a result such as "Deadline: 4 week(s) and 2 day(s)".

Tip: the values returned by this ViewHelper in both array and single value return modes, are also nicely consumable by the "math" suite of ViewHelpers, for example v:math.division would be able to divide number of days by two, three etc. to further divide the date range.

Arguments

start anySimpleType

Start date which can be a DateTime object or a string consumable by DateTime constructor

end anySimpleType

End date which can be a DateTime object or a string consumable by DateTime constructor

intervalFormat string

Interval format consumable by DateInterval

format string

Date format to apply to both start and end date

startFormat string

Date format to apply to start date

endFormat string

Date format to apply to end date

glue string

Glue string to concatenate dates with

spaceGlue boolean

If TRUE glue string is surrounded with whitespace

return anySimpleType

Return type; can be exactly "DateTime" to return a DateTime instance, a string like "w" or "d" to return weeks, days between the two dates - or an array of w, d, etc. strings to return the corresponding range count values as an array.

ViewHelper Resources

Schema Resources