discreteInput(after:)
The next discretization boundary after the given input.
Declaration
func discreteInput(after input: Range<Date>) -> Range<Date>?Return Value
If isPositive is true, the range input.lowerBound..<x, where x is the greatest date that is smaller than input.upperBound for which this style might produce a different FormatOutput. If isPositive is false, the range x..<input.upperBound, where x is the smallest date that is greater than input.lowerBound for which this style might produce a different FormatOutput. The function may return nil if there is no such value smaller or equal to input.upperBound.
Discussion
Use this function to determine the next greater input that warrants updating the formatted output. If isPositive is true, the returned range has the same lowerBound as the input, but increases the upperBound so that the returned range produces the next greater output. If isPositive is false, the returned range has the same upperBound as the input and a greater lowerBound.
let style = Date.ComponentsFormatStyle(style: .wide)
print(style.format(start..<end)) // "1 hour"
guard let next = style.discreteInput(after: start..<end) else {
return
}
print(style.format(next)) // "1 hour, 1 second"