<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/Date/ComponentsFormatStyle/discreteInput(after:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation4DateV21ComponentsFormatStyleV13discreteInput5afterSnyACGSgAH_tF"
  },
  "title" : "discreteInput(after:)"
}
-->

# discreteInput(after:)

The next discretization boundary after the given input.

```
func discreteInput(after input: Range<Date>) -> Range<Date>?
```

## Return Value

If [`isPositive`](/documentation/Foundation/Date/ComponentsFormatStyle/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`](/documentation/Foundation/FormatStyle/FormatOutput). If [`isPositive`](/documentation/Foundation/Date/ComponentsFormatStyle/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`](/documentation/Foundation/FormatStyle/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`](/documentation/Foundation/Date/ComponentsFormatStyle/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`](/documentation/Foundation/Date/ComponentsFormatStyle/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"
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)