---
title: "donatedWithin(_:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/sequence/donatedwithin(_:)"
---

# donatedWithin(_:)

Filters donations to only those that occurred within the specified time range.

## Declaration

```swift
func donatedWithin<DonationInfo>(_ timeRange: Tips.DonationTimeRange) -> [Self.Element] where DonationInfo : Decodable, DonationInfo : Encodable, DonationInfo : Sendable, Self.Element == Tips.Event<DonationInfo>.Donation
```

## Parameters

- `timeRange`: The time range to filter donations by.

## Return Value

Return Value An array of donations that occurred within the given time range.

## Discussion

Discussion Use this method inside a Tips/Rule predicate to constrain which donations are considered when evaluating tip eligibility. #Rule(AppEvents.didLogin) {     $0.donations.donatedWithin(.week).count >= 3 }
